Skip to content

HADOOP-19259. Upgrade to jackson 2.14.3 (#7428) #7622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
15 changes: 7 additions & 8 deletions LICENSE-binary
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,12 @@ com.aliyun:aliyun-java-sdk-sts:3.0.0
com.aliyun.oss:aliyun-sdk-oss:3.13.2
com.cedarsoftware:java-util:1.9.0
com.cedarsoftware:json-io:2.5.1
com.fasterxml.jackson.core:jackson-annotations:2.12.7
com.fasterxml.jackson.core:jackson-core:2.12.7
com.fasterxml.jackson.core:jackson-databind:2.12.7.1
com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.12.7
com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.12.7
com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.12.7
com.fasterxml.jackson.core:jackson-annotations:2.14.3
com.fasterxml.jackson.core:jackson-core:2.14.3
com.fasterxml.jackson.core:jackson-databind:2.14.3
com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:2.14.3
com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:2.14.3
com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.14.3
com.fasterxml.uuid:java-uuid-generator:3.1.4
com.fasterxml.woodstox:woodstox-core:5.4.0
com.github.davidmoten:rxjava-extras:0.8.0.17
Expand Down Expand Up @@ -508,8 +508,7 @@ javax.cache:cache-api:1.1.1
javax.servlet:javax.servlet-api:3.1.0
javax.servlet.jsp:jsp-api:2.1
javax.websocket:javax.websocket-api:1.0
javax.ws.rs:jsr311-api:1.1.1
javax.xml.bind:jaxb-api:2.2.11
javax.xml.bind:jaxb-api:2.3.1


Eclipse Public License 1.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.lang.reflect.Constructor;
import java.net.BindException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
Expand All @@ -46,10 +45,6 @@

import javax.net.SocketFactory;

import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.thirdparty.com.google.common.cache.Cache;
import org.apache.hadoop.thirdparty.com.google.common.cache.CacheBuilder;

import org.apache.commons.net.util.SubnetUtils;
import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
import org.apache.hadoop.classification.InterfaceAudience;
Expand All @@ -58,9 +53,13 @@
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.ipc.Server;
import org.apache.hadoop.ipc.VersionedProtocol;
import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.thirdparty.com.google.common.cache.Cache;
import org.apache.hadoop.thirdparty.com.google.common.cache.CacheBuilder;
import org.apache.hadoop.util.ReflectionUtils;
import org.apache.hadoop.util.Preconditions;
import org.apache.hadoop.util.dynamic.DynConstructors;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -941,10 +940,59 @@ public static IOException wrapException(final String destHost,

}
} catch (IOException ex) {
return (IOException) new IOException("Failed on local exception: "
+ exception + "; Host Details : "
+ getHostDetailsAsString(destHost, destPort, localHost))
.initCause(exception);
try {
return new IOException("Failed on local exception: "
+ exception + "; Host Details : "
+ getHostDetailsAsString(destHost, destPort, localHost), exception);
} catch (Exception ignore) {
// in worst case, return the original exception
return exception;
}
}
}

/**
* Return an @{@link IOException} of the same type as the input exception but with
* a modified exception message that includes the node name.
*
* @param ioe existing exception.
* @param nodeName name of the node.
* @return IOException
*/
public static IOException addNodeNameToIOException(final IOException ioe, final String nodeName) {
try {
final Throwable cause = ioe.getCause();
IOException newIoe = null;
if (cause != null) {
try {
DynConstructors.Ctor<? extends IOException> ctor =
new DynConstructors.Builder()
.impl(ioe.getClass(), String.class, Throwable.class)
.buildChecked();
newIoe = ctor.newInstance(nodeName + ": " + ioe.getMessage(), cause);
} catch (NoSuchMethodException e) {
// no matching constructor - try next approach below
}
}
if (newIoe == null) {
DynConstructors.Ctor<? extends IOException> ctor =
new DynConstructors.Builder()
.impl(ioe.getClass(), String.class)
.buildChecked();
newIoe = ctor.newInstance(nodeName + ": " + ioe.getMessage());
if (cause != null) {
try {
newIoe.initCause(cause);
} catch (Exception e) {
// Unable to initCause. Ignore the exception.
}
}
}
newIoe.setStackTrace(ioe.getStackTrace());
return newIoe;
} catch (Exception e) {
// Unable to create new exception. Return the original exception.
return ioe;
}
}

Expand All @@ -957,9 +1005,22 @@ private static <T extends IOException> T wrapWithMessage(
T exception, String msg) throws T {
Class<? extends Throwable> clazz = exception.getClass();
try {
Constructor<? extends Throwable> ctor = clazz.getConstructor(String.class);
Throwable t = ctor.newInstance(msg);
return (T)(t.initCause(exception));
try {
DynConstructors.Ctor<T> ctor =
new DynConstructors.Builder()
.impl(clazz, String.class, Throwable.class)
.buildChecked();
return ctor.newInstance(msg, exception);
} catch (NoSuchMethodException e) {
// no matching constructor - try next approach below
}
DynConstructors.Ctor<T> ctor =
new DynConstructors.Builder()
.impl(clazz, String.class)
.buildChecked();
T newException = ctor.newInstance(msg);
newException.initCause(exception);
return newException;
} catch (NoSuchMethodException e) {
return exception;
} catch (Throwable e) {
Expand Down Expand Up @@ -1114,7 +1175,7 @@ public static Set<Integer> getFreeSocketPorts(int numOfPorts) {

/**
* Return an @{@link InetAddress} to bind to. If bindWildCardAddress is true
* than returns null.
* then returns null.
*
* @param localAddr local addr.
* @param bindWildCardAddress bind wildcard address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.util.Enumeration;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipException;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -793,9 +794,57 @@ public void testBindToLocalAddress() throws Exception {
.bindToLocalAddress(NetUtils.getLocalInetAddress("127.0.0.1"), true));
}

public static class WrappedIOException extends IOException {
public WrappedIOException(String msg, Throwable cause) {
super(msg, cause);
}
}

private static class PrivateIOException extends IOException {
PrivateIOException(String msg, Throwable cause) {
super(msg, cause);
}
}

@Test
public void testAddNodeNameToIOException() {
IOException e0 = new IOException("test123");
assertNullCause(e0);
IOException new0 = NetUtils.addNodeNameToIOException(e0, "node123");
assertNullCause(new0);
assertEquals("node123: test123", new0.getMessage());

IOException e1 = new IOException("test456", new IllegalStateException("deliberate"));
IOException new1 = NetUtils.addNodeNameToIOException(e1, "node456");
assertSame(e1.getCause(), new1.getCause());
assertEquals("node456: test456", new1.getMessage());

ZipException e2 = new ZipException("test789");
assertNullCause(e2);
IOException new2 = NetUtils.addNodeNameToIOException(e2, "node789");
assertNullCause(new2);
assertEquals("node789: test789", new2.getMessage());

WrappedIOException e3 = new WrappedIOException("test987",
new IllegalStateException("deliberate"));
IOException new3 = NetUtils.addNodeNameToIOException(e3, "node987");
assertSame(e3.getCause(), new3.getCause());
assertEquals("node987: test987", new3.getMessage());

// addNodeNameToIOException will return the original exception if the class is not accessible
PrivateIOException e4 = new PrivateIOException("test654",
new IllegalStateException("deliberate"));
IOException new4 = NetUtils.addNodeNameToIOException(e4, "node654");
assertSame(e4, new4);
}

private <T> void assertBetterArrayEquals(T[] expect, T[]got) {
String expectStr = StringUtils.join(expect, ", ");
String gotStr = StringUtils.join(got, ", ");
assertEquals(expectStr, gotStr);
}

private void assertNullCause(Exception e) {
assertNull("Expected exception to have null cause", e.getCause());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -845,16 +844,7 @@ private T runWithRetry() throws IOException {
if (node == null) {
node = url.getAuthority();
}
try {
IOException newIoe = ioe.getClass().getConstructor(String.class)
.newInstance(node + ": " + ioe.getMessage());
newIoe.initCause(ioe.getCause());
newIoe.setStackTrace(ioe.getStackTrace());
ioe = newIoe;
} catch (NoSuchMethodException | SecurityException
| InstantiationException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
}
ioe = NetUtils.addNodeNameToIOException(ioe, node);
shouldRetry(ioe, retry);
}
}
Expand Down
4 changes: 2 additions & 2 deletions hadoop-project/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
<jersey.version>1.19.4</jersey.version>

<!-- jackson versions -->
<jackson2.version>2.12.7</jackson2.version>
<jackson2.databind.version>2.12.7.1</jackson2.databind.version>
<jackson2.version>2.14.3</jackson2.version>
<jackson2.databind.version>2.14.3</jackson2.databind.version>

<!-- httpcomponents versions -->
<httpclient.version>4.5.13</httpclient.version>
Expand Down