You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sqoop.apache.org by "Abraham Elmahrek (JIRA)" <ji...@apache.org> on 2014/11/17 22:30:34 UTC
[jira] [Comment Edited] (SQOOP-1748) Sqoop2: Client throws NPE when
misconfigured for Kerberos
[ https://issues.apache.org/jira/browse/SQOOP-1748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14215210#comment-14215210 ]
Abraham Elmahrek edited comment on SQOOP-1748 at 11/17/14 9:30 PM:
-------------------------------------------------------------------
I was looking at the code. It seems like we need a bit more exception handling:
{code:title=ResourceRequest.java}
if (responseCode == HttpURLConnection.HTTP_OK) {
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = reader.readLine();
while (line != null) {
result.append(line);
line = reader.readLine();
}
reader.close();
} else if (responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
/**
* Client filter to intercepting exceptions sent by sqoop server and
* recreating them on client side. Current implementation will create new
* instance of SqoopException and will attach original error code and message.
*
* Special handling for 500 internal server error in case that server
* has sent us it's exception correctly. We're using default route
* for all other 500 occurrences.
*/
if (conn.getHeaderFields().keySet().contains(
SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_CODE)) {
ThrowableBean ex = new ThrowableBean();
result = new StringBuilder();
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
String line = reader.readLine();
while (line != null) {
result.append(line);
line = reader.readLine();
}
reader.close();
JSONObject json = (JSONObject) JSONValue.parse(result.toString());
ex.restore(json);
throw new SqoopException(ClientError.CLIENT_0001, ex.getThrowable());
}
}
{code}
The above code should have an "else" clause that handles unknown return types.
was (Author: abec):
I was looking at the code. It seems like we need a bit more exception handling:
{code}
if (responseCode == HttpURLConnection.HTTP_OK) {
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = reader.readLine();
while (line != null) {
result.append(line);
line = reader.readLine();
}
reader.close();
} else if (responseCode == HttpURLConnection.HTTP_INTERNAL_ERROR) {
/**
* Client filter to intercepting exceptions sent by sqoop server and
* recreating them on client side. Current implementation will create new
* instance of SqoopException and will attach original error code and message.
*
* Special handling for 500 internal server error in case that server
* has sent us it's exception correctly. We're using default route
* for all other 500 occurrences.
*/
if (conn.getHeaderFields().keySet().contains(
SqoopProtocolConstants.HEADER_SQOOP_INTERNAL_ERROR_CODE)) {
ThrowableBean ex = new ThrowableBean();
result = new StringBuilder();
reader = new BufferedReader(new InputStreamReader(conn.getErrorStream()));
String line = reader.readLine();
while (line != null) {
result.append(line);
line = reader.readLine();
}
reader.close();
JSONObject json = (JSONObject) JSONValue.parse(result.toString());
ex.restore(json);
throw new SqoopException(ClientError.CLIENT_0001, ex.getThrowable());
}
}
{code}
The above code should have an "else" clause that handles unknown return types.
> Sqoop2: Client throws NPE when misconfigured for Kerberos
> ---------------------------------------------------------
>
> Key: SQOOP-1748
> URL: https://issues.apache.org/jira/browse/SQOOP-1748
> Project: Sqoop
> Issue Type: Bug
> Components: sqoop2-shell
> Affects Versions: 1.99.5
> Reporter: Abraham Elmahrek
> Fix For: 1.99.5
>
>
> {noformat}
> sqoop:000> show version --all
> client version:
> Sqoop 2.0.0-SNAPSHOT source revision 423de5d515545df2ca535d5ac5e84a4e9db30ba0
> Compiled by abe on Mon Nov 17 12:49:17 PST 2014
> Exception has occurred during processing command
> Exception: java.lang.NullPointerException Message: null
> Stack trace:
> at org.apache.sqoop.json.VersionBean (VersionBean.java:74)
> at org.apache.sqoop.client.request.VersionResourceRequest (VersionResourceRequest.java:31)
> at org.apache.sqoop.shell.ShowVersionFunction (ShowVersionFunction.java:112)
> at org.apache.sqoop.shell.ShowVersionFunction (ShowVersionFunction.java:65)
> at org.apache.sqoop.shell.SqoopFunction (SqoopFunction.java:51)
> at org.apache.sqoop.shell.SqoopCommand (SqoopCommand.java:127)
> at org.apache.sqoop.shell.SqoopCommand (SqoopCommand.java:103)
> at org.codehaus.groovy.tools.shell.Command$execute (null:-1)
> at org.codehaus.groovy.runtime.callsite.CallSiteArray (CallSiteArray.java:42)
> at org.codehaus.groovy.tools.shell.Command$execute (null:-1)
> at org.codehaus.groovy.tools.shell.Shell (Shell.groovy:101)
> at org.codehaus.groovy.tools.shell.Groovysh (Groovysh.groovy:-1)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:-2)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl (DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method (Method.java:606)
> at org.codehaus.groovy.reflection.CachedMethod (CachedMethod.java:90)
> at groovy.lang.MetaMethod (MetaMethod.java:233)
> at groovy.lang.MetaClassImpl (MetaClassImpl.java:1054)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter (ScriptBytecodeAdapter.java:128)
> at org.codehaus.groovy.tools.shell.Groovysh (Groovysh.groovy:173)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:-2)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl (DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method (Method.java:606)
> at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce (PogoMetaMethodSite.java:267)
> at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite (PogoMetaMethodSite.java:52)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite (AbstractCallSite.java:141)
> at org.codehaus.groovy.tools.shell.Groovysh (Groovysh.groovy:121)
> at org.codehaus.groovy.tools.shell.Shell (Shell.groovy:114)
> at org.codehaus.groovy.tools.shell.Shell$leftShift$0 (null:-1)
> at org.codehaus.groovy.tools.shell.ShellRunner (ShellRunner.groovy:88)
> at org.codehaus.groovy.tools.shell.InteractiveShellRunner (InteractiveShellRunner.groovy:-1)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:-2)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl (DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method (Method.java:606)
> at org.codehaus.groovy.reflection.CachedMethod (CachedMethod.java:90)
> at groovy.lang.MetaMethod (MetaMethod.java:233)
> at groovy.lang.MetaClassImpl (MetaClassImpl.java:1054)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter (ScriptBytecodeAdapter.java:128)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter (ScriptBytecodeAdapter.java:148)
> at org.codehaus.groovy.tools.shell.InteractiveShellRunner (InteractiveShellRunner.groovy:100)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:-2)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl (DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method (Method.java:606)
> at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce (PogoMetaMethodSite.java:267)
> at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite (PogoMetaMethodSite.java:52)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite (AbstractCallSite.java:137)
> at org.codehaus.groovy.tools.shell.ShellRunner (ShellRunner.groovy:57)
> at org.codehaus.groovy.tools.shell.InteractiveShellRunner (InteractiveShellRunner.groovy:-1)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:-2)
> at sun.reflect.NativeMethodAccessorImpl (NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl (DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method (Method.java:606)
> at org.codehaus.groovy.reflection.CachedMethod (CachedMethod.java:90)
> at groovy.lang.MetaMethod (MetaMethod.java:233)
> at groovy.lang.MetaClassImpl (MetaClassImpl.java:1054)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter (ScriptBytecodeAdapter.java:128)
> at org.codehaus.groovy.runtime.ScriptBytecodeAdapter (ScriptBytecodeAdapter.java:148)
> at org.codehaus.groovy.tools.shell.InteractiveShellRunner (InteractiveShellRunner.groovy:66)
> at java_lang_Runnable$run (null:-1)
> at org.codehaus.groovy.runtime.callsite.CallSiteArray (CallSiteArray.java:42)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite (AbstractCallSite.java:108)
> at org.codehaus.groovy.runtime.callsite.AbstractCallSite (AbstractCallSite.java:112)
> at org.codehaus.groovy.tools.shell.Groovysh (Groovysh.groovy:463)
> at org.codehaus.groovy.tools.shell.Groovysh (Groovysh.groovy:402)
> at org.apache.sqoop.shell.SqoopShell (SqoopShell.java:128)
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)