1
1
/*
2
- * Copyright 2002-2017 the original author or authors.
2
+ * Copyright 2002-2018 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.
@@ -86,10 +86,11 @@ final class HierarchicalUriComponents extends UriComponents {
86
86
this .userInfo = userInfo ;
87
87
this .host = host ;
88
88
this .port = port ;
89
- this .path = path != null ? path : NULL_PATH_COMPONENT ;
89
+ this .path = ( path != null ? path : NULL_PATH_COMPONENT ) ;
90
90
this .queryParams = CollectionUtils .unmodifiableMultiValueMap (
91
91
queryParams != null ? queryParams : new LinkedMultiValueMap <String , String >(0 ));
92
92
this .encoded = encoded ;
93
+
93
94
if (verify ) {
94
95
verify ();
95
96
}
@@ -668,7 +669,10 @@ public String getPath() {
668
669
669
670
@ Override
670
671
public List <String > getPathSegments () {
671
- String [] segments = StringUtils .tokenizeToStringArray (this .path , PATH_DELIMITER_STRING );
672
+ String [] segments = StringUtils .tokenizeToStringArray (getPath (), PATH_DELIMITER_STRING );
673
+ if (segments == null ) {
674
+ return Collections .emptyList ();
675
+ }
672
676
return Collections .unmodifiableList (Arrays .asList (segments ));
673
677
}
674
678
@@ -680,7 +684,7 @@ public PathComponent encode(String encoding) throws UnsupportedEncodingException
680
684
681
685
@ Override
682
686
public void verify () {
683
- verifyUriComponent (this . path , Type .PATH );
687
+ verifyUriComponent (getPath () , Type .PATH );
684
688
}
685
689
686
690
@ Override
@@ -697,12 +701,12 @@ public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
697
701
@ Override
698
702
public boolean equals (Object obj ) {
699
703
return (this == obj || (obj instanceof FullPathComponent &&
700
- getPath (). equals ( ((FullPathComponent ) obj ).getPath ())));
704
+ ObjectUtils . nullSafeEquals ( getPath (), ((FullPathComponent ) obj ).getPath ())));
701
705
}
702
706
703
707
@ Override
704
708
public int hashCode () {
705
- return getPath (). hashCode ( );
709
+ return ObjectUtils . nullSafeHashCode ( getPath ());
706
710
}
707
711
}
708
712
0 commit comments