Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Fixes NullPointerException in GraphErrorResponse#copy

## [2.0.16] - 2023-01-30

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public final AdditionalDataManager additionalDataManager() {
public GraphErrorResponse copy() {
GraphErrorResponse responseCopy = new GraphErrorResponse();
responseCopy.additionalDataManager = this.additionalDataManager;
responseCopy.rawObject = this.rawObject.deepCopy();
responseCopy.error = this.error.copy();
responseCopy.rawObject = this.rawObject == null ? null : this.rawObject.deepCopy();
responseCopy.error = this.error == null ? null : this.error.copy();
return responseCopy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;

import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -59,4 +60,18 @@ public void testGraphErrorResponseCopy() {

assertEquals(errorResponse.rawObject, errorResponseCopy.rawObject);
}

@Test
void testGraphErrorResponseCopy2() {
GraphErrorResponse errorResponse = new GraphErrorResponse();;

//Copy the errorResponse and its subsequent innerErrors
GraphErrorResponse errorResponseCopy = errorResponse.copy();

//Ensure default null values are copied without issue.
assertNull(errorResponseCopy.error);
assertNull(errorResponseCopy.rawObject);

assertEquals(errorResponse.rawObject, errorResponseCopy.rawObject);
}
}