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

NullPointerException in case of SocketTimeout occurred #121

Closed
aharbunou opened this issue Jan 17, 2017 · 6 comments
Closed

NullPointerException in case of SocketTimeout occurred #121

aharbunou opened this issue Jan 17, 2017 · 6 comments
Assignees

Comments

@aharbunou
Copy link

Hi! I've tried newest preview version "6.1.2-preview" and faced the following issue. When I set too small socket timeout like 30ms or less I have NullPointerException. I believe SocketTimeoutException should be instead. Please find full stacktrace below and let me know if you need more details.

java.lang.NullPointerException
at java.lang.StringBuilder.(StringBuilder.java:112)
at com.microsoft.sqlserver.jdbc.SQLServerException.checkAndAppendClientConnId(SQLServerException.java:348)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2507)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2491)
at com.microsoft.sqlserver.jdbc.TDSChannel.read(IOBuffer.java:2013)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.Prelogin(SQLServerConnection.java:2244)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2080)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:1731)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1562)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:855)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnectionInternal(SQLServerDataSource.java:842)
at com.microsoft.sqlserver.jdbc.SQLServerDataSource.getConnection(SQLServerDataSource.java:83)
at com.test.SoTimeoutTest.testSoTimeout(SoTimeoutTest.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:292)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

@xiangyushawn
Copy link
Contributor

@aharbunou thank you for filling this issue and providing very detailed stacktrace. We have provided a fix for this. I hope this PR will fix the problem. Thank you.

@v-nisidh
Copy link
Contributor

v-nisidh commented Feb 3, 2017

@aharbunou Can you able to validate if this fix is working on your end?

@aharbunou
Copy link
Author

Hi @v-nisidh.
Thank you @v-xiangs for the fix! Everything looks good now. I see SQLServerException instead of NullPointerExcpetion in case of timeouts. It will definitely improve our exception handling logic! Could you please provide some target date when new version will be available in Maven Central?
Also I have one comment for error handling in case of IOException. Is it possible to add the exception (SocketTimeoutException for our case) to SQLServerException as cause? We want to separate database timeouts from the rest of errors from SQL Server i.e. we need cause of SQLServerException. I understand that this is low priority enhancement for you but still I will be very appreciated if you could implement this.

@v-nisidh v-nisidh modified the milestone: Next Tasks Feb 6, 2017
@v-nisidh
Copy link
Contributor

v-nisidh commented Feb 7, 2017

@aharbunou : Can you close this defect and open new issue for adding cause to SQLServerException in this scenario.

We are working on pushing this fix on GitHub. We will give you updates.

@aharbunou
Copy link
Author

Thank you @v-nisidh! I've created #139 for the error handling enhancement.

@ajlam
Copy link
Member

ajlam commented Feb 7, 2017

@aharbunou the new jars for v6.1.3 have been pushed to Maven Central. Please check out this blog to learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants