Skip to content
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

HDFS-15474: Enable WebHdfsFileSystem to parse InvalidToken responce from HttpFS #7475

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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 @@ -520,7 +520,7 @@ private Path makeAbsolute(Path f) {
final Map<?, ?> m;
try {
m = jsonParse(conn, true);
} catch(Exception e) {
} catch (Exception e) {
throw new IOException("Unexpected HTTP response: code=" + code + " != "
+ op.getExpectedHttpResponseCode() + ", " + op.toQueryString()
+ ", message=" + conn.getResponseMessage(), e);
Expand All @@ -536,22 +536,28 @@ private Path makeAbsolute(Path f) {

IOException re = JsonUtilClient.toRemoteException(m);

//check if exception is due to communication with a Standby name node
if (re.getMessage() != null && re.getMessage().endsWith(
StandbyException.class.getSimpleName())) {
if (re.getMessage() == null) {
throw unwrapException ? toIOException(re) : re;
}

// check if exception is due to communication with a Standby name node
if (re.getMessage().endsWith(StandbyException.class.getSimpleName())) {
LOG.trace("Detected StandbyException", re);
throw new IOException(re);
}
// extract UGI-related exceptions and unwrap InvalidToken
// the NN mangles these exceptions but the DN does not and may need
// to re-fetch a token if either report the token is expired
if (re.getMessage() != null && re.getMessage().startsWith(
SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER)) {
String[] parts = re.getMessage().split(":\\s+", 3);
re = new RemoteException(parts[1], parts[2]);
re = ((RemoteException)re).unwrapRemoteException(InvalidToken.class);
}
throw unwrapException? toIOException(re): re;
if (re.getMessage().startsWith(SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER) ||
// For HttpFS responses, there is no header string
re.getMessage().startsWith(InvalidToken.class.getName() + ":")) {
final String invalidTokenMsg = re.getMessage()
.substring(re.getMessage().indexOf(InvalidToken.class.getName()));
String[] parts = invalidTokenMsg.split(":\\s+", 2);
re = new RemoteException(parts[0], parts[1]);
re = ((RemoteException) re).unwrapRemoteException(InvalidToken.class);
}
throw unwrapException ? toIOException(re) : re;
}
return null;
}
Expand Down
Loading