-
Notifications
You must be signed in to change notification settings - Fork 478
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
Runtime exceptions from chunkProccesor.process are not propagated #639
Labels
Comments
Can you give a example with Stacktrace ? |
I will prepare pull request, containing unit tests. |
rhajek
added a commit
to rhajek/influxdb-java
that referenced
this issue
Nov 22, 2019
Here is the example and unit test. This is the serious issue that causes the threads hangs/freeze because the client code is not notified when the async query is finished (onError/onComplete is not called). import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.influxdb.dto.Query;
import org.junit.Assert;
import org.junit.Test;
public class ChunkQueryExceptionTest {
private static Logger log = Logger.getLogger(ChunkQueryExceptionTest.class.getName());
@Test
public void testRuntimeException() throws Exception {
InfluxDB client = InfluxDBFactory.connect("http://localhost:8086", "root", "root");
CountDownLatch latch = new CountDownLatch(1);
client.query(new Query("Select (*) from cpu", "telegraf"), 2,
(cancellable, r) -> {
log.info("processing result: " + r.toString());
//any user code exception like parse 'null' to number...
throw new java.lang.NumberFormatException("my-chunk-processing-error");
// if any runtime exception is thrown while processing the chunk (processing si done in different thread)
// - call.cancel() is not called, so client does not stop streaming
// - client code is not notified that query was finished and hangs forever
// - exception is swallowed, it is not possible to catch and handle it
// - ugly workaround is to surround whole consumer lambda try/catch generic exception block
}, () -> log.info("Completed."),
(error) -> {
// check that the runtime exceptions are propagated here
if (error.getMessage().equals("my-chunk-processing-error")) {
latch.countDown();
}
log.log(Level.SEVERE, "Exception occured while query", error);
}
);
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
}
} |
majst01
added a commit
that referenced
this issue
Dec 2, 2019
Fixed exception propagation in query streaming #639
Fixed by PR #640 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Client code is not possible to handle runtime exceptions fired from chunk processing.
The text was updated successfully, but these errors were encountered: