Permalink
Browse files
[JENKINS-19990] Catch specific Exceptions.
- Loading branch information...
|
@@ -27,6 +27,8 @@ |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.PrintStream; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.IllegalCharsetNameException; |
|
|
|
import java.nio.charset.UnsupportedCharsetException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import org.apache.commons.lang.StringUtils; |
|
@@ -154,8 +156,10 @@ public FormValidation doCheckEncoding(@QueryParameter String encoding) { |
|
|
|
if (!StringUtils.isBlank(encoding)) { |
|
|
|
try { |
|
|
|
Charset.forName(encoding.trim()); |
|
|
|
} catch(Exception e) { |
|
|
|
return FormValidation.error(e, "Unsupported Encoding"); |
|
|
|
} catch(UnsupportedCharsetException e) { |
|
|
|
return FormValidation.error("Unsupported Encoding"); |
|
|
|
} catch(IllegalCharsetNameException e) { |
|
|
|
return FormValidation.error("Bad Encoding Name"); |
|
|
|
} |
|
|
|
if(!ParameterizedTriggerUtils.isSupportNonAsciiPropertiesFile()) { |
|
|
|
return FormValidation.warning("Non-ascii properties files are supported only since Java 1.6."); |
|
|
|
@@ -15,6 +15,8 @@ |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.nio.charset.Charset; |
|
|
|
import java.nio.charset.IllegalCharsetNameException; |
|
|
|
import java.nio.charset.UnsupportedCharsetException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
@@ -111,8 +113,10 @@ public FormValidation doCheckEncoding(@QueryParameter String encoding) { |
|
|
|
if (!StringUtils.isBlank(encoding)) { |
|
|
|
try { |
|
|
|
Charset.forName(encoding.trim()); |
|
|
|
} catch(Exception e) { |
|
|
|
return FormValidation.error(e, "Unsupported Encoding"); |
|
|
|
} catch(UnsupportedCharsetException e) { |
|
|
|
return FormValidation.error("Unsupported Encoding"); |
|
|
|
} catch(IllegalCharsetNameException e) { |
|
|
|
return FormValidation.error("Bad Encoding Name"); |
|
|
|
} |
|
|
|
if(!ParameterizedTriggerUtils.isSupportNonAsciiPropertiesFile()) { |
|
|
|
return FormValidation.warning("Non-ascii properties files are supported only since Java 1.6."); |
|
|
|
@@ -84,7 +84,7 @@ public static boolean isSupportNonAsciiPropertiesFile() { |
|
|
|
try { |
|
|
|
// Is {@link Properties#load(java.io.Reader)} supported? |
|
|
|
Properties.class.getMethod("load", Reader.class); |
|
|
|
} catch(Exception _) { |
|
|
|
} catch(NoSuchMethodException _) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
return true; |
|
|
0 comments on commit
48063b9