Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Stackoverflow with Immutables custom builder #3370

Copy link
Copy link

Description

@creckord
Issue body actions

Expected behavior

I have a value object making use of Immutables, which requires a customized builder class. It's defined like this:

@Value.Immutable
public abstract class ValueObject {
    public abstract String getFoo();
    public abstract Long getId();

    public static class Builder extends ImmutableValueObject.Builder {
       //some additional builder methods here
    }
}

And a POJO entity class like this:

public class ValueEntity {
    private String foo;
    protected Long id;

    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getFoo() { return foo; }
    public void setFoo(String foo) { this.foo = foo; }
}

And a simple Mapper definition that maps ValueEntity to ValueObject:

@Mapper
public abstract class Converter {
    public abstract ValueObject convert(ValueEntity valueEntity);
}

Expectation: The mapper implementation ConverterImpl is generated successfully and uses the builder generated by Immutables to create the ValueObject.

Actual behavior

Generating the mapper fails with a StackOverflowError in the annotation processor:

  	at org.mapstruct.ap.spi.ImmutablesBuilderProvider.findBuilderInfoForImmutables(ImmutablesBuilderProvider.java:58)
  	at org.mapstruct.ap.spi.ImmutablesBuilderProvider.findBuilderInfo(ImmutablesBuilderProvider.java:40)
  	at org.mapstruct.ap.spi.DefaultBuilderProvider.findBuilderInfo(DefaultBuilderProvider.java:96)
  	at org.mapstruct.ap.spi.DefaultBuilderProvider.findBuilderInfo(DefaultBuilderProvider.java:185)
  	at org.mapstruct.ap.spi.ImmutablesBuilderProvider.findBuilderInfoForImmutables(ImmutablesBuilderProvider.java:58)
  	at org.mapstruct.ap.spi.ImmutablesBuilderProvider.findBuilderInfo(ImmutablesBuilderProvider.java:40)
  	at org.mapstruct.ap.spi.DefaultBuilderProvider.findBuilderInfo(DefaultBuilderProvider.java:96)

Steps to reproduce the problem

Clone https://github.com/creckord/mapstruct-immutables-mcve and run ./gradlew clean classes

MapStruct Version

1.5.5

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugup-for-grabsIssues targeted for community contributionIssues targeted for community contribution

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.