Skip to content

Apache HttpClient 4 to 5 does not yet migrate StringEntity.setContentEncoding() to constructor argument #54

@FieteO

Description

@FieteO

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v2.0.0

How are you running OpenRewrite?

I am running the spring boot 3.1 migration via the command line:

mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1 -Drewrite.exportDatatables=true

What is the smallest, simplest way to reproduce the problem?

import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;

class A {
        void foo() {
                StringEntity se = new StringEntity("", ContentType.APPLICATION_JSON);
                se.setContentEncoding("utf-8");
        }
}

What did you expect to see?

import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.io.entity.StringEntity;

class A {
        void foo() {
                StringEntity se = new StringEntity("", ContentType.APPLICATION_JSON, "utf-8", false);
        }
}

Note that the fourth constructor parameter (chunked) of StringEntity is set to false based on the default value that is used by the smaller constructor:

Image

What did you see instead?

setContentEncoding is not replaced with setting the value via the constructor.

import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.io.entity.StringEntity;

class A {
        void foo(String bar) {
                StringEntity se = new StringEntity("", ContentType.APPLICATION_JSON);
                se.setContentEncoding("utf-8");
        }
}

Are you interested in contributing a fix to OpenRewrite?

No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingrecipe

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions