5454import java .util .concurrent .ThreadFactory ;
5555import java .util .concurrent .ThreadPoolExecutor ;
5656
57- import org .apache .commons .lang3 .StringUtils ;
5857import org .apache .commons .logging .Log ;
5958import org .apache .commons .logging .LogFactory ;
6059import org .apache .http .NoHttpResponseException ;
9897import org .htmlunit .util .HeaderUtils ;
9998import org .htmlunit .util .MimeType ;
10099import org .htmlunit .util .NameValuePair ;
100+ import org .htmlunit .util .StringUtils ;
101101import org .htmlunit .util .UrlUtils ;
102102import org .htmlunit .websocket .JettyWebSocketAdapter .JettyWebSocketAdapterFactory ;
103103import org .htmlunit .websocket .WebSocketAdapter ;
@@ -624,13 +624,13 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
624624 && (forceAttachmentWithFilename != null || attachmentHandler_ .isAttachment (webResponse ))) {
625625
626626 // check content disposition header for nothing provided
627- if (StringUtils .isEmpty (forceAttachmentWithFilename )) {
627+ if (StringUtils .isEmptyOrNull (forceAttachmentWithFilename )) {
628628 final String disp = webResponse .getResponseHeaderValue (HttpHeader .CONTENT_DISPOSITION );
629629 forceAttachmentWithFilename = Attachment .getSuggestedFilename (disp );
630630 }
631631
632632 if (attachmentHandler_ .handleAttachment (webResponse ,
633- StringUtils .isEmpty (forceAttachmentWithFilename ) ? null : forceAttachmentWithFilename )) {
633+ StringUtils .isEmptyOrNull (forceAttachmentWithFilename ) ? null : forceAttachmentWithFilename )) {
634634 // the handling is done by the attachment handler;
635635 // do not open a new window
636636 return webWindow .getEnclosedPage ();
@@ -639,7 +639,8 @@ public Page loadWebResponseInto(final WebResponse webResponse, final WebWindow w
639639 final WebWindow w = openWindow (null , null , webWindow );
640640 final Page page = pageCreator_ .createPage (webResponse , w );
641641 attachmentHandler_ .handleAttachment (page ,
642- StringUtils .isEmpty (forceAttachmentWithFilename ) ? null : forceAttachmentWithFilename );
642+ StringUtils .isEmptyOrNull (forceAttachmentWithFilename )
643+ ? null : forceAttachmentWithFilename );
643644 return page ;
644645 }
645646
@@ -1383,8 +1384,9 @@ private static WebResponse makeWebResponseForAboutUrl(final WebRequest webReques
13831384 return new StringWebResponse ("" , UrlUtils .URL_ABOUT_BLANK );
13841385 }
13851386
1386- final String urlWithoutQuery = StringUtils .substringBefore (urlString , "?" );
1387- if (!"blank" .equalsIgnoreCase (StringUtils .substringAfter (urlWithoutQuery , UrlUtils .ABOUT_SCHEME ))) {
1387+ final String urlWithoutQuery = org .apache .commons .lang3 .StringUtils .substringBefore (urlString , "?" );
1388+ if (!"blank" .equalsIgnoreCase (org .apache .commons .lang3 .StringUtils
1389+ .substringAfter (urlWithoutQuery , UrlUtils .ABOUT_SCHEME ))) {
13881390 throw new MalformedURLException (url + " is not supported, only about:blank is supported at the moment." );
13891391 }
13901392 return new StringWebResponse ("" , url );
@@ -1423,7 +1425,7 @@ private WebResponse makeWebResponseForFileUrl(final WebRequest webRequest) throw
14231425 compiledHeaders .add (new NameValuePair (HttpHeader .CONTENT_TYPE , MimeType .TEXT_HTML ));
14241426 final WebResponseData responseData =
14251427 new WebResponseData (
1426- org . htmlunit . util . StringUtils
1428+ StringUtils
14271429 .toByteArray ("File: " + file .getAbsolutePath (), UTF_8 ),
14281430 404 , "Not Found" , compiledHeaders );
14291431 return new WebResponse (responseData , webRequest , 0 );
@@ -1451,13 +1453,13 @@ private WebResponse makeWebResponseForBlobUrl(final WebRequest webRequest) {
14511453
14521454 final List <NameValuePair > headers = new ArrayList <>();
14531455 final String type = fileOrBlob .getType ();
1454- if (!StringUtils .isEmpty (type )) {
1456+ if (!StringUtils .isEmptyOrNull (type )) {
14551457 headers .add (new NameValuePair (HttpHeader .CONTENT_TYPE , fileOrBlob .getType ()));
14561458 }
14571459 if (fileOrBlob instanceof org .htmlunit .javascript .host .file .File ) {
14581460 final org .htmlunit .javascript .host .file .File file = (org .htmlunit .javascript .host .file .File ) fileOrBlob ;
14591461 final String fileName = file .getName ();
1460- if (!StringUtils .isEmpty (fileName )) {
1462+ if (!StringUtils .isEmptyOrNull (fileName )) {
14611463 // https://datatracker.ietf.org/doc/html/rfc6266#autoid-10
14621464 headers .add (new NameValuePair (HttpHeader .CONTENT_DISPOSITION , "inline; filename=\" " + fileName + "\" " ));
14631465 }
0 commit comments