|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2016 the original author or authors. |
| 2 | + * Copyright 2012-2017 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -71,8 +71,6 @@ public class Handler extends URLStreamHandler {
|
71 | 71 | rootFileCache = new SoftReference<Map<File, JarFile>>(null);
|
72 | 72 | }
|
73 | 73 |
|
74 |
| - private final Logger logger = Logger.getLogger(getClass().getName()); |
75 |
| - |
76 | 74 | private final JarFile jarFile;
|
77 | 75 |
|
78 | 76 | private URLStreamHandler fallbackHandler;
|
@@ -105,17 +103,29 @@ private URLConnection openFallbackConnection(URL url, Exception reason)
|
105 | 103 | }
|
106 | 104 | catch (Exception ex) {
|
107 | 105 | if (reason instanceof IOException) {
|
108 |
| - this.logger.log(Level.FINEST, "Unable to open fallback handler", ex); |
| 106 | + log(false, "Unable to open fallback handler", ex); |
109 | 107 | throw (IOException) reason;
|
110 | 108 | }
|
111 |
| - this.logger.log(Level.WARNING, "Unable to open fallback handler", ex); |
| 109 | + log(true, "Unable to open fallback handler", ex); |
112 | 110 | if (reason instanceof RuntimeException) {
|
113 | 111 | throw (RuntimeException) reason;
|
114 | 112 | }
|
115 | 113 | throw new IllegalStateException(reason);
|
116 | 114 | }
|
117 | 115 | }
|
118 | 116 |
|
| 117 | + private void log(boolean warning, String message, Exception cause) { |
| 118 | + try { |
| 119 | + Logger.getLogger(getClass().getName()) |
| 120 | + .log((warning ? Level.WARNING : Level.FINEST), message, cause); |
| 121 | + } |
| 122 | + catch (Exception ex) { |
| 123 | + if (warning) { |
| 124 | + System.err.println("WARNING: " + message); |
| 125 | + } |
| 126 | + } |
| 127 | + } |
| 128 | + |
119 | 129 | private URLStreamHandler getFallbackHandler() {
|
120 | 130 | if (this.fallbackHandler != null) {
|
121 | 131 | return this.fallbackHandler;
|
|
0 commit comments