196 */
197 private static JarFile retrieve(final URL url, final URLJarFileCloseController closeController) throws IOException {
198 /*
199 * See if interface is set, then call retrieve function of the class
200 * that implements URLJarFileCallBack interface (sun.plugin - to
201 * handle the cache failure for JARJAR file.)
202 */
203 if (callback != null)
204 {
205 return callback.retrieve(url);
206 }
207
208 else
209 {
210
211 JarFile result = null;
212
213 /* get the stream before asserting privileges */
214 try (final InputStream in = url.openConnection().getInputStream()) {
215 result = AccessController.doPrivileged(
216 new PrivilegedExceptionAction<JarFile>() {
217 public JarFile run() throws IOException {
218 Path tmpFile = Files.createTempFile("jar_cache", null);
219 try {
220 Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING);
221 JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController);
222 tmpFile.toFile().deleteOnExit();
223 return jarFile;
224 } catch (Throwable thr) {
225 try {
226 Files.delete(tmpFile);
227 } catch (IOException ioe) {
228 thr.addSuppressed(ioe);
229 }
230 throw thr;
231 }
232 }
233 });
234 } catch (PrivilegedActionException pae) {
235 throw (IOException) pae.getException();
236 }
|
196 */
197 private static JarFile retrieve(final URL url, final URLJarFileCloseController closeController) throws IOException {
198 /*
199 * See if interface is set, then call retrieve function of the class
200 * that implements URLJarFileCallBack interface (sun.plugin - to
201 * handle the cache failure for JARJAR file.)
202 */
203 if (callback != null)
204 {
205 return callback.retrieve(url);
206 }
207
208 else
209 {
210
211 JarFile result = null;
212
213 /* get the stream before asserting privileges */
214 try (final InputStream in = url.openConnection().getInputStream()) {
215 result = AccessController.doPrivileged(
216 new PrivilegedExceptionAction<>() {
217 public JarFile run() throws IOException {
218 Path tmpFile = Files.createTempFile("jar_cache", null);
219 try {
220 Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING);
221 JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController);
222 tmpFile.toFile().deleteOnExit();
223 return jarFile;
224 } catch (Throwable thr) {
225 try {
226 Files.delete(tmpFile);
227 } catch (IOException ioe) {
228 thr.addSuppressed(ioe);
229 }
230 throw thr;
231 }
232 }
233 });
234 } catch (PrivilegedActionException pae) {
235 throw (IOException) pae.getException();
236 }
|