mapstruct / mapstruct/mapstruct-examples
mapstruct-protobuf3 use lombok:UnsupportedOperationException(Collections$UnmodifiableCollection)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 504
- PR merge metrics
- No merged PRs in 30d
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with mapstruct-protobuf3/usage/pom.xml and inspect the annotationProcessorPaths configuration shown in the issue. Rebuild the mapstruct-protobuf3 example and run mapstruct-protobuf3/usage/src/test/.../ProtobufTest.java, checking the generated UserMapperImpl.java code and confirming that the test completes without UnsupportedOperationException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100