Summary
Specify a file system related constraint in the existing @throws
declaration of HttpRequest.BodyPublisher::ofFile
.
Problem
The original specification of BodyPublisher::ofFile
assumed that the given path belongs to the default file system or behaves as such, and would fail if this was not the case. A fix is proposed to enable BodyPublisher::ofFile
to work with other file system path implementations. Accordingly, a specification change should clarify when a SecurityException
is thrown, depending on the file system of the given path.
Solution
Specify the conditions of when a SecurityException
is thrown, which is only in the case of the system-default file system provider.
Specification
java.net.http.HttpRequest.BodyPublishers
- * @throws SecurityException if a security manager has been installed
- * and it denies {@link SecurityManager#checkRead(String)
- * read access} to the given file
+ * @throws SecurityException if opening the file for reading is denied:
+ * in the case of the system-default file system provider, and
+ * a security manager is installed,
+ * {@link SecurityManager#checkRead(String) checkRead}
+ * is invoked to check read access to the given file
*/
public static BodyPublisher ofFile(Path path) throws FileNotFoundException {
- csr of
-
JDK-8235459 HttpRequest.BodyPublishers#ofFile(Path) assumes the default file system
- Closed