11/*
2- * Copyright 2002-2017 the original author or authors.
2+ * Copyright 2002-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -86,10 +86,11 @@ final class HierarchicalUriComponents extends UriComponents {
8686 this .userInfo = userInfo ;
8787 this .host = host ;
8888 this .port = port ;
89- this .path = path != null ? path : NULL_PATH_COMPONENT ;
89+ this .path = ( path != null ? path : NULL_PATH_COMPONENT ) ;
9090 this .queryParams = CollectionUtils .unmodifiableMultiValueMap (
9191 queryParams != null ? queryParams : new LinkedMultiValueMap <String , String >(0 ));
9292 this .encoded = encoded ;
93+
9394 if (verify ) {
9495 verify ();
9596 }
@@ -668,7 +669,10 @@ public String getPath() {
668669
669670 @ Override
670671 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+ }
672676 return Collections .unmodifiableList (Arrays .asList (segments ));
673677 }
674678
@@ -680,7 +684,7 @@ public PathComponent encode(String encoding) throws UnsupportedEncodingException
680684
681685 @ Override
682686 public void verify () {
683- verifyUriComponent (this . path , Type .PATH );
687+ verifyUriComponent (getPath () , Type .PATH );
684688 }
685689
686690 @ Override
@@ -697,12 +701,12 @@ public void copyToUriComponentsBuilder(UriComponentsBuilder builder) {
697701 @ Override
698702 public boolean equals (Object obj ) {
699703 return (this == obj || (obj instanceof FullPathComponent &&
700- getPath (). equals ( ((FullPathComponent ) obj ).getPath ())));
704+ ObjectUtils . nullSafeEquals ( getPath (), ((FullPathComponent ) obj ).getPath ())));
701705 }
702706
703707 @ Override
704708 public int hashCode () {
705- return getPath (). hashCode ( );
709+ return ObjectUtils . nullSafeHashCode ( getPath ());
706710 }
707711 }
708712
0 commit comments