SocketTimeoutException - "timeout" "read timed out" - exception

I am writing tests which run OkHttp/Retrofit requests against a MockWebServer. Among other things I'm testing timeouts. Here I noticed, that some of my timeout tests do not produce the same kind of exception all the time:
While the exception thrown is always a SocketTimeoutException, the exception message differs between two possibilities. Sometimes I get
"timeout", sometimes
"Read timed out".
There seems to be no clear pattern (it's the very same test which sometimes produces one or the other of these exception messages).
I assume that different constellations/causes lead to the differing messages... Can somebody explain to me the difference between these two cases?
Here are the corresponding stack traces:
"Read timed out"
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio$2.read(Okio.java:140)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:238)
at okio.RealBufferedSource.read(RealBufferedSource.java:45)
at okhttp3.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:381)
at okio.RealBufferedSource.read(RealBufferedSource.java:45)
at okio.ForwardingSource.read(ForwardingSource.java:35)
at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:279)
at okio.RealBufferedSource$1.read(RealBufferedSource.java:386)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1287)
at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1016)
at com.google.gson.stream.JsonReader.nextName(JsonReader.java:787)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714)
at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.java:910)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106)
"timeout"
Caused by: java.net.SocketTimeoutException: timeout
at okio.Okio$3.newTimeoutException(Okio.java:212)
at okio.AsyncTimeout.exit(AsyncTimeout.java:288)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:242)
at okio.RealBufferedSource.read(RealBufferedSource.java:45)
at okhttp3.internal.http.Http1xStream$FixedLengthSource.read(Http1xStream.java:381)
at okio.RealBufferedSource.read(RealBufferedSource.java:45)
at okio.ForwardingSource.read(ForwardingSource.java:35)
at retrofit2.OkHttpCall$ExceptionCatchingRequestBody$1.read(OkHttpCall.java:279)
at okio.RealBufferedSource$1.read(RealBufferedSource.java:386)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at com.google.gson.stream.JsonReader.fillBuffer(JsonReader.java:1287)
at com.google.gson.stream.JsonReader.nextQuotedValue(JsonReader.java:1016)
at com.google.gson.stream.JsonReader.nextName(JsonReader.java:787)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:739)
at com.google.gson.internal.bind.TypeAdapters$29.read(TypeAdapters.java:714)
at com.google.gson.internal.bind.TypeAdapters$35$1.read(TypeAdapters.java:910)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:37)
at retrofit2.converter.gson.GsonResponseBodyConverter.convert(GsonResponseBodyConverter.java:25)
at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:117)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:211)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:106)

Related

jOOQ - Get Connection URL from a DataAccessException

In case jOOQ can't connect to a database, executing SQL against it will result in a DataAccessException.
Is there a way to get the url of the database/connection against which the query was attempted, just from this error?
Edit, adding more context:
We have a simple connection pooling implementation using a HashMap and its computeIfAbsent().
If DSL.using(url) does not throw an Exception, we consider the connection established and keep the resulting DSLContext as value in said map (url is key).
Assume there are multiple connections in the pool.
We have an ExecuteListener attached to the DSLContext and in it, we catch DataAccessExceptions. When caught, we validate the connection with: executeContext.dsl().diagnosticsConnection().isValid(1).
If the connection became invalid, we would like to flag it as such but the only way to find out which one it is, is to loop over the connection pool map because executeContext.dsl().parsingConnection().getMetaData().getURL() is no longer an option.
Here's an example stack trace. It's different for each of the DB engines we connect to but always wrapped in org.jooq.exception.DataAccessException.
org.jooq.exception.DataAccessException: SQL [select count(*) from (select * from actor) as `alias_4914265`]; (conn=1) unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.jooq_3.12.3.MARIADB.debug(Unknown Source)
at org.jooq.impl.Tools.translate(Tools.java:2717)
at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:755)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:382)
at org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:501)
at org.jooq.impl.AbstractResultQuery.fetchLazy(AbstractResultQuery.java:470)
at org.jooq.impl.AbstractResultQuery.fetchLazyNonAutoClosing(AbstractResultQuery.java:484)
at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:653)
at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:605)
at org.jooq.impl.AbstractResultQuery.fetchOne(AbstractResultQuery.java:611)
at org.jooq.impl.SelectImpl.fetchOne(SelectImpl.java:2847)
at com.datoris.base.AbstractBaseTypeImpl.executeReport(AbstractBaseTypeImpl.java:134)
at com.datoris.service.ReportService.executeReport(ReportService.java:508)
at com.datoris.verticle.ReportVerticle.lambda$completeStartup$0(ReportVerticle.java:29)
at io.vertx.core.eventbus.impl.HandlerRegistration.deliver(HandlerRegistration.java:261)
at io.vertx.core.eventbus.impl.HandlerRegistration.handle(HandlerRegistration.java:239)
at io.vertx.core.eventbus.impl.EventBusImpl$InboundDeliveryContext.next(EventBusImpl.java:565)
at io.vertx.core.eventbus.impl.EventBusImpl.lambda$deliverToHandler$5(EventBusImpl.java:524)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
at io.vertx.core.impl.WorkerContext.lambda$wrapTask$0(WorkerContext.java:34)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.sql.SQLNonTransientConnectionException: (conn=1) unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:240)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:171)
at org.mariadb.jdbc.MariaDbStatement.executeExceptionEpilogue(MariaDbStatement.java:248)
at org.mariadb.jdbc.ClientSidePreparedStatement.executeInternal(ClientSidePreparedStatement.java:230)
at org.mariadb.jdbc.ClientSidePreparedStatement.execute(ClientSidePreparedStatement.java:157)
at org.jooq.tools.jdbc.DefaultPreparedStatement.execute(DefaultPreparedStatement.java:209)
at org.jooq.impl.Tools.executeStatementAndGetFirstResultSet(Tools.java:3928)
at org.jooq.impl.AbstractResultQuery.execute(AbstractResultQuery.java:294)
at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:368)
... 20 common frames omitted
Caused by: java.sql.SQLNonTransientConnectionException: unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.handleIoException(AbstractQueryProtocol.java:1925)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1437)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1415)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.executeQuery(AbstractQueryProtocol.java:289)
at org.mariadb.jdbc.ClientSidePreparedStatement.executeInternal(ClientSidePreparedStatement.java:221)
... 25 common frames omitted
Caused by: java.io.EOFException: unexpected end of stream, read 0 bytes from 4 (socket was closed by server)
at org.mariadb.jdbc.internal.io.input.StandardPacketInputStream.getPacketArray(StandardPacketInputStream.java:246)
at org.mariadb.jdbc.internal.io.input.StandardPacketInputStream.getPacket(StandardPacketInputStream.java:215)
at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1435)
... 28 common frames omitted

Neo4j-import fails

I'm trying to import a dataset using neo4j-import. Unfortunately the import fails with the following error message which is not saying much to me. Does anyone has an idea?
Thank you
The command was:
./neo4j-import --into /home_expes/dd77474h/neo4j-community-3.0.7/data/databases/graph.db/ --nodes /home_expes/dd77474h/Indexing-server/reduced_dbpedia_nodes.csv --relationships /home_expes/dd77474h/Indexing-server/reduced_dbpedia_relations.csv --stacktrace true --id-type
reduced_dbpedia_nodes.csv:
id:ID,uri,:LABEL
7,"http://dbpedia.org/resource/Albedo",Resource
reduced_dbpedia_relations.csv
:START_ID,:END_ID,:TYPE
1,2,"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
Error message:
Relationship --> Relationship Sparse
[>:231.50 MB/s--------------------------|LINK(3)==|*v:130.76 MB/s-----------------------------] 171M
Done in 24s 824ms
Minority relationships
[*INSERT--------------------------------------------------------------------------------------] 540K
Done in 14m 31s 126ms
Count groups
[*>:??----------------------------------------------------------------------------|COUNT------]12.2M
Done in 2s 786ms
Gather
java.lang.RuntimeException: Panic called, so exiting
at org.neo4j.unsafe.impl.batchimport.staging.AbstractStep.assertHealthy(AbstractStep.java:155)
at org.neo4j.unsafe.impl.batchimport.staging.ProducerStep.process(ProducerStep.java:84)
at org.neo4j.unsafe.impl.batchimport.staging.ProducerStep$1.run(ProducerStep.java:54)
Caused by: java.lang.IllegalStateException: There's no room for me for startIndex:28899 with a group count of -25966. This means that there's an asymmetry between calls to incrementGroupCount and actual contents sent into put
at org.neo4j.unsafe.impl.batchimport.RelationshipGroupCache.scanForFreeFrom(RelationshipGroupCache.java:203)
at org.neo4j.unsafe.impl.batchimport.RelationshipGroupCache.put(RelationshipGroupCache.java:159)
at org.neo4j.unsafe.impl.batchimport.CacheGroupsStep.process(CacheGroupsStep.java:48)
at org.neo4j.unsafe.impl.batchimport.CacheGroupsStep.process(CacheGroupsStep.java:31)
at org.neo4j.unsafe.impl.batchimport.staging.ProcessorStep.lambda$receive$2(ProcessorStep.java:97)
at org.neo4j.unsafe.impl.batchimport.executor.DynamicTaskExecutor$Processor.run(DynamicTaskExecutor.java:243)
Import error: Panic called, so exiting
Caused by:Panic called, so exiting
java.lang.RuntimeException: Panic called, so exiting
at org.neo4j.unsafe.impl.batchimport.staging.AbstractStep.assertHealthy(AbstractStep.java:155)
at org.neo4j.unsafe.impl.batchimport.staging.ProducerStep.process(ProducerStep.java:84)
at org.neo4j.unsafe.impl.batchimport.staging.ProducerStep$1.run(ProducerStep.java:54)
Caused by: java.lang.IllegalStateException: There's no room for me for startIndex:28899 with a group count of -25966. This means that there's an asymmetry between calls to incrementGroupCount and actual contents sent into put
at org.neo4j.unsafe.impl.batchimport.RelationshipGroupCache.scanForFreeFrom(RelationshipGroupCache.java:203)
at org.neo4j.unsafe.impl.batchimport.RelationshipGroupCache.put(RelationshipGroupCache.java:159)
at org.neo4j.unsafe.impl.batchimport.CacheGroupsStep.process(CacheGroupsStep.java:48)
at org.neo4j.unsafe.impl.batchimport.CacheGroupsStep.process(CacheGroupsStep.java:31)
at org.neo4j.unsafe.impl.batchimport.staging.ProcessorStep.lambda$receive$2(ProcessorStep.java:97)
at org.neo4j.unsafe.impl.batchimport.executor.DynamicTaskExecutor$Processor.run(DynamicTaskExecutor.java:243)
Thanks for your help, I found the bug. FYI see https://github.com/neo4j/neo4j/pull/8778 for fix.

Handle only certain exceptions in Camel sub-route

Thanks to this question I know that I need to specify errorHandler(noErrorHandler()) in a sub-route in order for exceptions to be propagated to the parent route in Camel. However I would like to handle some exceptions in the sub-route but propagate the rest to the parent.
For example:
from("direct:top")
.onException(Exception.class)
.log("Top-level: ${exception}")
.continued(true)
.end()
.to("mock:start")
.to("direct:sub1")
.to("direct:sub2")
.end();
from("direct:sub1")
.errorHandler(noErrorHandler())
.to("mock:sub1")
.throwException(new IllegalArgumentException("test"));
from("direct:sub2")
.onException(IllegalArgumentException.class)
.log("Sub2: ${exception}")
.continued(true)
.end()
// but I want all other exceptions to be propagated to the top handler
.to("mock:sub2")
.throwException(new IllegalArgumentException("test"))
.throwException(new NullPointerException("test"));
sub1 works as expected, but I'd like sub2 to locally handle and log the IllegalArgumentException and allow the NullPointerException to bubble up to the parent. However, my log output looks like this:
10:35:28.048 [main] INFO route1 - Top-level: java.lang.IllegalArgumentException: test
10:35:28.049 [main] INFO route3 - Sub2: java.lang.IllegalArgumentException: test
10:35:28.056 [main] ERROR DefaultErrorHandler - Failed delivery for (MessageId: xxxx on ExchangeId: xxx). Exhausted after delivery attempt: 1 caught: java.lang.NullPointerException: test
If I add errorHandler(noErrorHandler()) to sub2 the IllegalArgumentException is propagated to the parent (which I don't want) and the NullPointerException isn't logged at all. Is there any way to achieve my desired behaviour?
When you throw an exception the exception is cought and route ends immediately, so the second exception can't be thrown. If you want to throw the second exception only if the first one occurs you should throw it from onException block (before .end)

java.lang.ExceptionInInitializerError while running the JUNIT method

I have been running a simple Junit testclass with a single test method.
I am stuck with the below error.
The stackTrace is as follows
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:263)
at com.ibm.ws.webservices.engine.soap.SAAJMetaFactoryImpl.newMessageFactory(SAAJMetaFactoryImpl.java:56)
at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:159)
at com.sun.xml.internal.ws.api.SOAPVersion.<init>(SOAPVersion.java:179)
at com.sun.xml.internal.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:84)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
at com.sun.xml.internal.ws.api.BindingID.<clinit>(BindingID.java:336)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseBinding(RuntimeWSDLParser.java:425)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:322)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:147)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:267)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:178)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:57)
Can anyone help me what could be the reason behind it
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j) (Caused by org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)
at com.ibm.ws.webservices.engine.components.logger.LogFactory$1.run(LogFactory.java:119)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.webservices.engine.components.logger.LogFactory.getLog(LogFactory.java:111)
at com.ibm.ws.webservices.engine.soap.MessageFactoryImpl.<clinit>(MessageFactoryImpl.java:103)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:241)
... 41 more
Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j (Caused by java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:416)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)
... 48 more
Caused by: java.lang.UnsupportedOperationException: Operation [getContextClassLoader] is not supported in jcl-over-slf4j. See also http://www.slf4j.org/codes.html#unsupported_operation_in_jcl_over_slf4j
at org.apache.commons.logging.LogFactory.getContextClassLoader(LogFactory.java:366)
at org.apache.commons.logging.impl.LogFactoryImpl.access$000(LogFactoryImpl.java:113)
at org.apache.commons.logging.impl.LogFactoryImpl$1.run(LogFactoryImpl.java:457)
at java.security.AccessController.doPrivileged(AccessController.java:229)
at org.apache.commons.logging.impl.LogFactoryImpl.loadClass(LogFactoryImpl.java:454)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:406)
... 49 more
I did not have to add any jar files to the CLASSPATH though. I solved it by adding the following system property:
-Dorg.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.SLF4JLogFactory
is this mandatory in running the webservices through JUNit?

Exception of type 'System.OutOfMemoryException' was thrown

I have an application which throws "Exception of type 'System.OutOfMemoryException'". Which reduces the performance of the server,the CPU usage was around 95%.
I dont know the reason why this problem is occuring ....
can any one pls tell wats the reason for the error and how can i sort it out????
This is my stack trace:
Message
Exception of type 'System.OutOfMemoryException' was thrown.
Source
MySql.Data
Stack
at MySql.Data.MySqlClient.MySqlParameterCollection..ctor() at
MySql.Data.MySqlClient.MySqlCommand..ctor() at
MySql.Data.MySqlClient.MySqlConnection.CreateDbCommand() at
System.Data.Common.DbConnection.System.Data.IDbConnection.CreateCommand() at
IBatisNet.Common.DbProvider.CreateDataParameter() at
IBatisNet.DataMapper.SqlMapSession.CreateDataParameter() at
IBatisNet.DataMapper.Configuration.Statements.PreparedStatementFactory.CreateParametersForTextCommand() at IBatisNet.DataMapper