Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ public Object createFromString(DeserializationContext ctxt, String value) throws
if (_fromStringCreator != null) {
try {
return _fromStringCreator.call1(value);
} catch (Throwable t) {
} catch (Exception t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these (in this class) make sense.

return ctxt.handleInstantiationProblem(_fromStringCreator.getDeclaringClass(),
value, rewrapCtorProblem(ctxt, t));
}
Expand All @@ -357,7 +357,7 @@ public Object createFromInt(DeserializationContext ctxt, int value) throws IOExc
Object arg = Integer.valueOf(value);
try {
return _fromIntCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromIntCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0));
}
Expand All @@ -367,7 +367,7 @@ public Object createFromInt(DeserializationContext ctxt, int value) throws IOExc
Object arg = Long.valueOf(value);
try {
return _fromLongCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromLongCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0));
}
Expand All @@ -377,7 +377,7 @@ public Object createFromInt(DeserializationContext ctxt, int value) throws IOExc
Object arg = BigInteger.valueOf(value);
try {
return _fromBigIntegerCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromBigIntegerCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0)
);
Expand All @@ -394,7 +394,7 @@ public Object createFromLong(DeserializationContext ctxt, long value) throws IOE
Long arg = Long.valueOf(value);
try {
return _fromLongCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromLongCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0)
);
Expand All @@ -405,7 +405,7 @@ arg, rewrapCtorProblem(ctxt, t0)
BigInteger arg = BigInteger.valueOf(value);
try {
return _fromBigIntegerCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromBigIntegerCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0)
);
Expand All @@ -421,7 +421,7 @@ public Object createFromBigInteger(DeserializationContext ctxt, BigInteger value
if (_fromBigIntegerCreator != null) {
try {
return _fromBigIntegerCreator.call1(value);
} catch (Throwable t) {
} catch (Exception t) {
return ctxt.handleInstantiationProblem(_fromBigIntegerCreator.getDeclaringClass(),
value, rewrapCtorProblem(ctxt, t)
);
Expand All @@ -438,7 +438,7 @@ public Object createFromDouble(DeserializationContext ctxt, double value) throws
Double arg = Double.valueOf(value);
try {
return _fromDoubleCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromDoubleCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0));
}
Expand All @@ -448,7 +448,7 @@ public Object createFromDouble(DeserializationContext ctxt, double value) throws
BigDecimal arg = BigDecimal.valueOf(value);
try {
return _fromBigDecimalCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromBigDecimalCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0));
}
Expand All @@ -463,7 +463,7 @@ public Object createFromBigDecimal(DeserializationContext ctxt, BigDecimal value
if (_fromBigDecimalCreator != null) {
try {
return _fromBigDecimalCreator.call1(value);
} catch (Throwable t) {
} catch (Exception t) {
return ctxt.handleInstantiationProblem(_fromBigDecimalCreator.getDeclaringClass(),
value, rewrapCtorProblem(ctxt, t)
);
Expand All @@ -479,7 +479,7 @@ value, rewrapCtorProblem(ctxt, t)
if (dbl != null) {
try {
return _fromDoubleCreator.call1(dbl);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromDoubleCreator.getDeclaringClass(),
dbl, rewrapCtorProblem(ctxt, t0));
}
Expand Down Expand Up @@ -507,7 +507,7 @@ public Object createFromBoolean(DeserializationContext ctxt, boolean value) thro
final Boolean arg = Boolean.valueOf(value);
try {
return _fromBooleanCreator.call1(arg);
} catch (Throwable t0) {
} catch (Exception t0) {
return ctxt.handleInstantiationProblem(_fromBooleanCreator.getDeclaringClass(),
arg, rewrapCtorProblem(ctxt, t0));
}
Expand Down Expand Up @@ -654,7 +654,7 @@ private Object _createUsingDelegate(AnnotatedWithParams delegateCreator,
}
// and then try calling with full set of arguments
return delegateCreator.call(args);
} catch (Throwable t) {
} catch (Exception t) {
throw rewrapCtorProblem(ctxt, t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,15 @@ public abstract class DOMDeserializer<T> extends FromStringDeserializer<T>
parserFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch(ParserConfigurationException pce) {
// not much point to do anything; could log but...
} catch (Error e) {
// 14-Jul-2016, tatu: Not sure how or why, but during code coverage runs
// (via Cobertura) we get `java.lang.AbstractMethodError` so... ignore that too
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// 14-Jul-2016, tatu: Not sure how or why, but during code coverage runs
// (via Cobertura) we get java.lang.AbstractMethodError so... ignore that too

There was no trace of code coverage tool named Cobertura in databind.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why catch Exception though? Remove the Error catching but don't add the Exception handling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, let's just remove altogether in this case.But careful with following ones.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, keep catching ParserConfigurationException in line 36 right? Just to be sure

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep all checks except for the Error check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.


// [databind#2589] add two more settings just in case
try {
parserFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
} catch (Throwable t) { } // as per previous one, nothing much to do
} catch (Exception t) { } // as per previous one, nothing much to do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case need to leave Exception like here, for unsupported feature.

(or could consider catching ParserConfigurationException -- but for now I prefer Exception).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case need to leave Exception like here, for unsupported feature.

I do prefer ParserConfigurationException for exact same reason because setFeature method itself is documented to throw ParserConfigurationException for unsupported feature. Then question becomes "can we trust javax.xml.parsers and its documentation?" 😅

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. I do not (alas!) trust them NOT to throw, say, IllegalArgumentException (or NPE as actually documented).
And I say this as maintainer of Woodstox which tries to follow API spec but which still occasional has differed (esp. where spec was incomplete).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exception it is then~

try {
parserFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
} catch (Throwable t) { } // as per previous one, nothing much to do
} catch (Exception t) { } // as per previous one, nothing much to do
DEFAULT_PARSER_FACTORY = parserFactory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.spi.FileSystemProvider;
import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;

import com.fasterxml.jackson.core.JsonParser;
Expand Down Expand Up @@ -77,11 +78,11 @@ public Path deserialize(JsonParser p, DeserializationContext ctxt) throws IOExce
}
}
return (Path) ctxt.handleInstantiationProblem(handledType(), value, cause);
} catch (Throwable e) {
} catch (ServiceConfigurationError e) {
e.addSuppressed(cause);
return (Path) ctxt.handleInstantiationProblem(handledType(), value, e);
}
} catch (Throwable e) {
} catch (Exception e) {
return (Path) ctxt.handleInstantiationProblem(handledType(), value, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1300,10 +1300,10 @@ public static Method[] getClassMethods(Class<?> cls)
}
try {
return contextClass.getDeclaredMethods(); // Cross fingers
} catch (Throwable t) {
} catch (Exception t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I think, can change to only catch Exception

return _failGetClassMethods(cls, t);
}
} catch (Throwable t) {
} catch (Exception t) {
return _failGetClassMethods(cls, t);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class StdDateFormat
+"(\\.\\d+)?" // optional second fractions
+"(Z|[+-]\\d\\d(?:[:]?\\d\\d)?)?" // optional timeoffset/Z
);
} catch (Throwable t) {
} catch (Exception t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense.

throw new RuntimeException(t);
}
PATTERN_ISO8601 = p;
Expand Down