@@ -148,8 +148,8 @@ public void buildResourcePaths() {
148
148
return ;
149
149
}
150
150
151
- Map <String ,URL > paths = new HashMap <String , URL >();
152
- Stack <String > q = new Stack <String >();
151
+ Map <String ,URL > paths = new HashMap <>();
152
+ Stack <String > q = new Stack <>();
153
153
q .push ("/" );
154
154
while (!q .isEmpty ()) {
155
155
String dir = q .pop ();
@@ -576,7 +576,7 @@ boolean serveStaticResource(HttpServletRequest req, StaplerResponse rsp, InputSt
576
576
// Need to duplicate this logic from ResponseImpl.getCompressedOutputStream,
577
577
// since we want to set content length if we are not using encoding.
578
578
String acceptEncoding = req .getHeader ("Accept-Encoding" );
579
- if (acceptEncoding != null && acceptEncoding .indexOf ("gzip" ) != - 1 ) {
579
+ if (acceptEncoding != null && acceptEncoding .contains ("gzip" )) {
580
580
// with gzip compression, Content-Length header needs to indicate the # of bytes after compression,
581
581
// so we can't compute it upfront.
582
582
out = rsp .getCompressedOutputStream (req );
@@ -682,7 +682,7 @@ private String getMimeType(String fileName) {
682
682
* Performs stapler processing on the given root object and request URL.
683
683
*/
684
684
public void invoke (HttpServletRequest req , HttpServletResponse rsp , Object root , String url ) throws IOException , ServletException {
685
- RequestImpl sreq = new RequestImpl (this , req , new ArrayList <AncestorImpl >(), new TokenList (url ));
685
+ RequestImpl sreq = new RequestImpl (this , req , new ArrayList <>(), new TokenList (url ));
686
686
RequestImpl oreq = CURRENT_REQUEST .get ();
687
687
CURRENT_REQUEST .set (sreq );
688
688
@@ -1019,24 +1019,22 @@ public static Stapler getCurrent() {
1019
1019
* HTTP date format. Notice that {@link SimpleDateFormat} is thread unsafe.
1020
1020
*/
1021
1021
static final ThreadLocal <SimpleDateFormat > HTTP_DATE_FORMAT =
1022
- new ThreadLocal <SimpleDateFormat >() {
1023
- protected @ Override SimpleDateFormat initialValue () {
1022
+ ThreadLocal .withInitial (() -> {
1024
1023
// RFC1945 section 3.3 Date/Time Formats states that timezones must be in GMT
1025
1024
SimpleDateFormat format = new SimpleDateFormat ("EEE, dd MMM yyyy HH:mm:ss zzz" , Locale .US );
1026
1025
format .setTimeZone (TimeZone .getTimeZone ("GMT" ));
1027
1026
return format ;
1028
- }
1029
- };
1027
+ });
1030
1028
1031
- /*package*/ static ThreadLocal <RequestImpl > CURRENT_REQUEST = new ThreadLocal <RequestImpl >();
1032
- /*package*/ static ThreadLocal <ResponseImpl > CURRENT_RESPONSE = new ThreadLocal <ResponseImpl >();
1029
+ /*package*/ static ThreadLocal <RequestImpl > CURRENT_REQUEST = new ThreadLocal <>();
1030
+ /*package*/ static ThreadLocal <ResponseImpl > CURRENT_RESPONSE = new ThreadLocal <>();
1033
1031
1034
1032
private static final Logger LOGGER = Logger .getLogger (Stapler .class .getName ());
1035
1033
1036
1034
/**
1037
1035
* Extensions that look like text files.
1038
1036
*/
1039
- private static final Set <String > TEXT_FILES = new HashSet <String >(Arrays .asList (
1037
+ private static final Set <String > TEXT_FILES = new HashSet <>(Arrays .asList (
1040
1038
"css" ,"js" ,"html" ,"txt" ,"java" ,"htm" ,"c" ,"cpp" ,"h" ,"rb" ,"pl" ,"py" ,"xml" ,"json"
1041
1039
));
1042
1040
@@ -1052,7 +1050,7 @@ public static Stapler getCurrent() {
1052
1050
* which is a security risk. Fix that by normalizing them.
1053
1051
*/
1054
1052
static String canonicalPath (String path ) {
1055
- List <String > r = new ArrayList <String >(Arrays .asList (path .split ("/+" )));
1053
+ List <String > r = new ArrayList <>(Arrays .asList (path .split ("/+" )));
1056
1054
for (int i =0 ; i <r .size (); ) {
1057
1055
if (r .get (i ).length ()==0 || r .get (i ).equals ("." )) {
1058
1056
// empty token occurs for example, "".split("/+") is [""]
@@ -1146,9 +1144,7 @@ public FileItem convert(Class type, Object value) {
1146
1144
if (value ==null ) return null ;
1147
1145
try {
1148
1146
return Stapler .getCurrentRequest ().getFileItem (value .toString ());
1149
- } catch (ServletException e ) {
1150
- throw new ConversionException (e );
1151
- } catch (IOException e ) {
1147
+ } catch (ServletException | IOException e ) {
1152
1148
throw new ConversionException (e );
1153
1149
}
1154
1150
}
0 commit comments