Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
minzhiwu opened this issue Oct 25, 2022 · 0 comments

Comments

@minzhiwu
Copy link

minzhiwu commented Oct 25, 2022

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?

@minzhiwu minzhiwu reopened this Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant