File tree Expand file tree Collapse file tree 4 files changed +9
-5
lines changed 
test/java/sortpom/wrapper Expand file tree Collapse file tree 4 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 77 * in XmlProcessor.PatchedXMLWriter 
88 */ 
99public  class  NewlineText  extends  AbstractText  {
10-   public  static  final  NewlineText  INSTANCE  = new  NewlineText ();
1110  private  static  final  long  serialVersionUID  = -7552189498553321263L ;
1211
13-   private  NewlineText () {}
14- 
1512  /** 
1613   * This returns a <code>String</code> representation of the <code>NewlineText</code>, suitable for 
1714   * debugging. 
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ Wrapper<Node> createWrapper(Text text) {
3636    return  new  UnsortedWrapper <>(text );
3737  }
3838
39-   private   boolean  isElementSpacePreserved (Element  element ) {
39+   boolean  isElementSpacePreserved (Element  element ) {
4040    if  (element  == null ) {
4141      return  false ;
4242    }
Original file line number Diff line number Diff line change 77/** A wrapper that lets is element be unsorted */ 
88public  class  UnsortedWrapper <T  extends  Node > implements  Wrapper <T > {
99  public  static  final  UnsortedWrapper <Node > NEWLINE_TEXT_WRAPPER_INSTANCE  =
10-       new  UnsortedWrapper <>(NewlineText . INSTANCE );
10+       new  UnsortedWrapper <>(new   NewlineText () );
1111
1212  /** The wrapped dom content. */ 
1313  private  final  T  content ;
Original file line number Diff line number Diff line change 33import  static  org .junit .jupiter .api .Assertions .assertFalse ;
44import  static  org .junit .jupiter .api .Assertions .assertTrue ;
55
6+ import  org .dom4j .dom .DOMText ;
67import  org .dom4j .tree .DefaultText ;
78import  org .junit .jupiter .api .BeforeEach ;
89import  org .junit .jupiter .api .Test ;
@@ -40,4 +41,10 @@ void testIsEmptyLine() {
4041    assertTrue (textWrapperCreator .isBlankLineOrLines (new  DefaultText ("\r \n \r \n " )));
4142    assertFalse (textWrapperCreator .isBlankLineOrLines (new  DefaultText ("  " )));
4243  }
44+ 
45+   @ Test 
46+   void  textNodeWithNullParentShouldNotCrash () {
47+     var  text  = new  DOMText ("Hi!" );
48+     assertFalse (textWrapperCreator .isElementSpacePreserved (text .getParent ()));
49+   }
4350}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments