Comments (2)
I have updated the code by doing some research, but now continually get the error
"java.util.concurrent.atomic.AtomicReferenceFieldUpdater.compareAndSet(Object, Object, Object)" because "org.asynchttpclient.netty.NettyResponseFuture.EX_EX_UPDATER" is null
[AsyncHttpClient-4-27] ERROR org.asynchttpclient.netty.handler.HttpHandler - Cannot invoke "java.util.concurrent.atomic.AtomicReferenceFieldUpdater.compareAndSet(Object, Object, Object)" because "org.asynchttpclient.netty.NettyResponseFuture.EX_EX_UPDATER" is null
java.lang.NullPointerException: Cannot invoke "java.util.concurrent.atomic.AtomicReferenceFieldUpdater.compareAndSet(Object, Object, Object)" because "org.asynchttpclient.netty.NettyResponseFuture.EX_EX_UPDATER" is null
at org.asynchttpclient.netty.NettyResponseFuture.abort(NettyResponseFuture.java:239)
at org.asynchttpclient.netty.request.NettyRequestSender.abort(NettyRequestSender.java:392)
at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.exceptionCaught(AsyncHttpClientHandler.java:211)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:209)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:209)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:209)
at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireExceptionCaught(CombinedChannelDuplexHandler.java:416)
at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:79)
at io.netty.channel.CombinedChannelDuplexHandler$1.fireExceptionCaught(CombinedChannelDuplexHandler.java:144)
at io.netty.channel.ChannelInboundHandlerAdapter.exceptionCaught(ChannelInboundHandlerAdapter.java:131)
at io.netty.channel.CombinedChannelDuplexHandler.exceptionCaught(CombinedChannelDuplexHandler.java:223)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:209)
at io.netty.channel.ChannelHandlerAdapter.exceptionCaught(ChannelHandlerAdapter.java:79)
at io.netty.channel.AbstractChannelHandlerContext.invokeExceptionCaught(AbstractChannelHandlerContext.java:230)
at io.netty.channel.AbstractChannelHandlerContext.fireExceptionCaught(AbstractChannelHandlerContext.java:209)
at io.netty.channel.DefaultChannelPipeline.fireExceptionCaught(DefaultChannelPipeline.java:950)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.handleReadException(AbstractNioByteChannel.java:87)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:162)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:528)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:447)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:401)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:371)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
at java.base/java.lang.Thread.run(Thread.java:1589)
I will continue investigating, but if anyone has a quick fix, please share!
/* Thread class */
public TaskProcessor() {
AsyncHttpClientConfig config = new DefaultAsyncHttpClientConfig.Builder().build();
this.c = asyncHttpClient(config);
}
public void processNextTask() {
ProxyServer proxy1 = new ProxyServer.Builder("proxy1.example.com", 8080).build();
Request request1 = new RequestBuilder("GET")
.setUrl("http://example.com/")
//.setProxyServer(proxy1)
.build();
c.executeRequest(request1, new handler(c, this));
}
/* consumer class */
import org.asynchttpclient.*;
import java.io.IOException;
public class handler implements AsyncHandler<Integer> {
private final AsyncHttpClient c;
private final TaskProcessor processor;
private Integer status;
public handler(AsyncHttpClient c, TaskProcessor TaskProcessor) {
this.c = c;
this.processor = TaskProcessor;
}
@Override
public AsyncHandler.State onStatusReceived(HttpResponseStatus responseStatus) throws Exception {
status = responseStatus.getStatusCode();
if(status >= 200 && status < 400){
this.processor.getScraper().logger.increaseSuccessRequestCount();
} else {
this.processor.getScraper().logger.increaseFailedRequestCount();
}
return AsyncHandler.State.ABORT;
}
@Override
public AsyncHandler.State onHeadersReceived(HttpResponseHeaders headers) throws Exception {
return AsyncHandler.State.ABORT;
}
@Override
public AsyncHandler.State onBodyPartReceived(HttpResponseBodyPart bodyPart) throws Exception {
return AsyncHandler.State.ABORT;
}
@Override
public Integer onCompleted() throws Exception{
return status;
}
@Override
public void onThrowable(Throwable t) {
}
}
from async-http-client.
Looks like this was patched in the latest version!
from async-http-client.
Related Issues (20)
- Integrating async-http-client into OSS-Fuzz HOT 3
- Remove `Authorization` header on redirects? HOT 1
- JakartaEE Release??? HOT 4
- Add configuration options to enable HttpClientCodec.allowDuplicateContentLengths flag HOT 1
- The code seems to spam org.asynchttpclient.netty.channel.NettyChannelConnector$1.operationComplete() HOT 4
- GetResponseBody() seems to crash, return no errors HOT 1
- Is hostname certifcate validation enabled by default? HOT 1
- How to use SSL proxy with AHC HOT 5
- Exception `java.util.NoSuchElementException: socks` when making https request with socks5 proxy HOT 2
- Shutdown is slow
- Remotely closed RemotelyClosedException
- Netty security issues (CVE-2022-41915 and CVE-2021-43797) HOT 1
- Netty security issues (CVE-2022-41915 and CVE-2021-43797) HOT 3
- use promise mode,MaxConnectionSemaphore do not relase lock until channel close. HOT 2
- Invalid Status code=400 text=Bad Request
- JakartaEE and Java 21 issues
- Setting Loglevel HOT 1
- Requests should take ByteBuf as input data in efficient manner HOT 1
- Response and HttpResponseBodyPart should return ByteBuf HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from async-http-client.