Skip to content

mapstruct-protobuf3 use lombok:UnsupportedOperationException(Collections$UnmodifiableCollection) #142

@minzhiwu

Description

@minzhiwu

modify mapstruct-protobuf3/usage/pom.xml plugin config,

                <annotationProcessorPaths>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${org.mapstruct.version}</version>
                    </path>

                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${org.projectlombok.version}</version>
                    </path>

                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-mapstruct-binding</artifactId>
                        <version>${lombok-mapstruct-binding.version}</version>
                    </path>

                    <path>
                        <!-- Add your SPI implementation. -->
                        <groupId>org.mapstruct.examples.spi</groupId>
                        <artifactId>protobuf-spi-impl</artifactId>
                        <version>1.0.0</version>
                    </path>

                </annotationProcessorPaths>
   `

rebuild the mapstruct-protobuf3, run the test,report an error
java.lang.UnsupportedOperationException at java.util.Collections$UnmodifiableCollection.addAll(Collections.java:1065) at org.mapstruct.example.mapper.UserMapperImpl.map(UserMapperImpl.java:34) at org.mapstruct.example.ProtobufTest.test(ProtobufTest.java:33),

Partially generated code

if ( userDTO.getMainDepartmentsList() != null ) {
           List<UserProtos.DepartmentDTO> list = departmentListToDepartmentDTOList( user.getMainDepartments() );
            if ( list != null ) {
                userDTO.getMainDepartmentsList().addAll( list );
            }

        }
        if ( userDTO.getDepartmentsList() != null ) {

            List<UserProtos.DepartmentDTO> list1 = departmentListToDepartmentDTOList( user.getDepartments() );
            if ( list1 != null ) {
                userDTO.getDepartmentsList().addAll( list1 );
            }

recover mapstruct-protobuf3/usage/pom.xml plugin config, run test success.
Is there any way to solve this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions