Comments (11)
As far as I can see the constructor of the HttpPostRequestEncoder.java doesn't allow creation of the object if the method is different from POST
public HttpPostRequestEncoder(
HttpDataFactory factory, HttpRequest request, boolean multipart, Charset charset,
EncoderMode encoderMode)
throws ErrorDataEncoderException {
if (factory == null) {
throw new NullPointerException("factory");
}
if (request == null) {
throw new NullPointerException("request");
}
if (charset == null) {
throw new NullPointerException("charset");
}
if (request.getMethod() != HttpMethod.POST) {
throw new ErrorDataEncoderException("Cannot create a Encoder if not a POST");
}
.......
}
As you can see in the implementation of setRequestParameters in the EtcdNettyClient you allow creation of this encoder even if the method is PUT.
private static HttpRequest setRequestParameters(String uri, EtcdRequest<?> etcdRequest, HttpRequest httpRequest) throws Exception {
// Set possible key value pairs
Map<String, String> keyValuePairs = etcdRequest.getRequestParams();
if (keyValuePairs != null && !keyValuePairs.isEmpty()) {
HttpMethod etcdRequestMethod = etcdRequest.getMethod();
if (etcdRequestMethod == HttpMethod.POST || etcdRequestMethod == HttpMethod.PUT) {
HttpPostRequestEncoder bodyRequestEncoder = new HttpPostRequestEncoder(httpRequest, false);
....
}
I think this should be fixed.
from etcd4j.
Hi,
I don't see the exception, and I see a different source for HttpPostRequestEncoder, where PUT is allowed:
public HttpPostRequestEncoder(
HttpDataFactory factory, HttpRequest request, boolean multipart, Charset charset,
EncoderMode encoderMode)
throws ErrorDataEncoderException {
if (factory == null) {
throw new NullPointerException("factory");
}
if (request == null) {
throw new NullPointerException("request");
}
if (charset == null) {
throw new NullPointerException("charset");
}
HttpMethod method = request.method();
if (!(method.equals(HttpMethod.POST) || method.equals(HttpMethod.PUT)
|| method.equals(HttpMethod.PATCH) || method.equals(HttpMethod.OPTIONS))) {
throw new ErrorDataEncoderException("Cannot create a Encoder if not a POST");
}
...
Do have another netty-codec-http version on your classpath? The one used in etcd4j is io.netty:netty-codec-http:4.1.0.Beta3, see build.gradle
Regards, Marc
from etcd4j.
Yeah I'm using 4.0.25 Final... And obviously in the newer version they changed the api. I changed it to 4.1.3Beta and it worked. Well i'm not using gradle. I'm using this library from Maven.
from etcd4j.
👍
from etcd4j.
Btw I think project must be packaged with all of it's dependencies because as you can see I can't know which version of the netty api is used. And since i use always final versions that was a problem in this case.
from etcd4j.
I don't agree with this. You can see the dependencies with version numbers in the build.gradle file: https://github.com/jurmous/etcd4j/blob/master/build.gradle#L42. If if you don't use gradle, you still can use that information to add the dependencies to your maven pom file (like you did obviously) or on any other way you prefer to your classpath.
If every library comes packaged with every dependency, you will have chaos on your classpath sooner or later, when different libraries use different versions of dependencies.
Oh wait, it's even easier: why do you not just add etcd4j to your pom file? That should resolve all dependencies automatically, not? http://search.maven.org/#artifactdetails%7Corg.mousio%7Cetcd4j%7C2.1.0%7Cjar
from etcd4j.
Oh, no, won't work. The pom of etcd4j does not contain all dependencies.
@jurmous I think the tooling for uploading to the maven repository does not understand the "clientCompile" you use in the build.gradle file... 😕
from etcd4j.
Oh dear. Something is indeed wrong with the gradle build. Gradle maven plugin by default only includes the dependencies of the main sourceSet which in this case does not include Netty. I have opened #27 with a more specific description and will look into it tomorrow. Thanks for reporting this issue in!
I will also look into back porting to the final Netty 4.0 release since those betas take much longer time to mature than I was expecting when I started this project.
from etcd4j.
Glad that i helped :)
from etcd4j.
Released in 2.1.1 :)
I could not easily convert back to Final because of the issue reported above which prevented to use the Post decoder with the Put. So I left the dependency at Beta for this moment. Maybe I will look into this issue later if I can solve it differently.
from etcd4j.
Now it works like a charm. No need to add any additional libraries.
Just added this one and all deps are resolved and included.
<dependency>
<groupId>org.mousio</groupId>
<artifactId>etcd4j</artifactId>
<version>2.1.1</version>
</dependency>
Thank you
from etcd4j.
Related Issues (20)
- API changes report for Etcd4j
- etcd4j supports backup HOT 3
- how to use etcd4j with SSL HOT 9
- Got exception when i try to use etcd4j v2.13.0 in Apache Felix v5.6.1 HOT 1
- Release HOT 8
- How long will support etcd 3?
- How long will support etcd 3? HOT 1
- Connecting to a etcd cluster using dns server name instead of IP HOT 3
- Does etcd4j support etcd version 3.2.18 HOT 1
- Update dependency on jackson-databind to 2.8.11.1 or later? HOT 2
- o.netty.util.concurrent.BlockingOperationException: DefaultPromise@357ccd6b(incomplete) #112 HOT 2
- Timeout or connection timeout is not working. HOT 5
- mousio.etcd4j.EtcdClient.getDir(String) has no effect HOT 3
- the mistake of README.md
- this support connection pool ?
- ByteBuf not released
- may it cause a concurrent problem while using ResponsePromise.addListene method? HOT 3
- any plan to upgrade to jackson 2.9.*
- EtcdResponsePromise get(), response is not null and no exception happened but throw new IOException HOT 2
- there is no exception reported
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 etcd4j.