File tree 2 files changed +13
-1
lines changed
spring-boot-tools/spring-boot-loader/src
main/java/org/springframework/boot/loader/jar
test/java/org/springframework/boot/loader/jar 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -449,7 +449,7 @@ public String getName() {
449
449
* {@link URLStreamHandler} will be located to deal with jar URLs.
450
450
*/
451
451
public static void registerUrlProtocolHandler () {
452
- String handlers = System .getProperty (PROTOCOL_HANDLER );
452
+ String handlers = System .getProperty (PROTOCOL_HANDLER , "" );
453
453
System .setProperty (PROTOCOL_HANDLER , ("" .equals (handlers ) ? HANDLERS_PACKAGE
454
454
: handlers + "|" + HANDLERS_PACKAGE ));
455
455
resetCachedUrlHandlers ();
Original file line number Diff line number Diff line change 43
43
import org .springframework .util .FileCopyUtils ;
44
44
import org .springframework .util .StreamUtils ;
45
45
46
+ import static org .hamcrest .Matchers .containsString ;
46
47
import static org .hamcrest .Matchers .equalTo ;
47
48
import static org .hamcrest .Matchers .greaterThan ;
48
49
import static org .hamcrest .Matchers .instanceOf ;
49
50
import static org .hamcrest .Matchers .is ;
51
+ import static org .hamcrest .Matchers .not ;
50
52
import static org .hamcrest .Matchers .notNullValue ;
51
53
import static org .hamcrest .Matchers .nullValue ;
52
54
import static org .hamcrest .Matchers .sameInstance ;
63
65
* @author Andy Wilkinson
64
66
*/
65
67
public class JarFileTests {
68
+ private static final String PROTOCOL_HANDLER = "java.protocol.handler.pkgs" ;
69
+
70
+ private static final String HANDLERS_PACKAGE = "org.springframework.boot.loader" ;
66
71
67
72
@ Rule
68
73
public ExpectedException thrown = ExpectedException .none ();
@@ -453,4 +458,11 @@ public void cannotLoadMissingJar() throws Exception {
453
458
url .openConnection ().getInputStream ();
454
459
}
455
460
461
+ @ Test
462
+ public void registerUrlProtocolHandler () {
463
+ JarFile .registerUrlProtocolHandler ();
464
+ String protocolHandler = System .getProperty (PROTOCOL_HANDLER );
465
+ assertThat (protocolHandler , containsString (HANDLERS_PACKAGE ));
466
+ assertThat (protocolHandler , not (containsString ("null" )));
467
+ }
456
468
}
You can’t perform that action at this time.
0 commit comments