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

Make root field transient in all classes #1004

Merged
merged 6 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
24 changes: 16 additions & 8 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -1208,26 +1208,34 @@ public Reader renderMarkdown(String text) throws IOException {
}

/**
* Do not use this method. This method will be removed and should never have been needed in the first place.
* Gets an {@link ObjectWriter} that can be used to convert data objects in this library to JSON.
*
* If you must convert data object in this library to JSON, the {@link ObjectWriter} returned by this method is the
* only support way of doing so. This {@link ObjectWriter} can be used to convert any library data object to JSON
bitwiseman marked this conversation as resolved.
Show resolved Hide resolved
* without throwing an exception.
*
* WARNING: While the JSON generated is generally expected to be stable, it is not part of the API of this library
* and may change without warning. Use with extreme caution.
*
* @return an {@link ObjectWriter} instance that can be further configured.
* @deprecated DO NOT USE THIS METHOD. Provided for backward compatibility with projects that did their own jackson
* mapping of this project's data objects, such as Jenkins Blue Ocean.
*/
@Deprecated
@Nonnull
public static ObjectWriter getMappingObjectWriter() {
return GitHubClient.getMappingObjectWriter();
}

/**
* Do not use this method. This method will be removed and should never have been needed in the first place.
* Gets an {@link ObjectReader} that can be used to convert JSON into library data objects.
*
* If you must manually create library data objects from JSON, the {@link ObjectReader} returned by this method is
* the only supported way of doing so.
*
* WARNING: Objects generated from this method have limited functionality. They will not throw when being crated
* from valid JSON matching the expected object, but they are not guaranteed to be usable beyond that. Use with
* extreme caution.
*
* @return an {@link ObjectReader} instance that can be further configured.
* @deprecated DO NOT USE THIS METHOD. Provided for backward compatibility with projects that did their own jackson
* mapping of this project's data objects, such as Jenkins Blue Ocean.
*/
@Deprecated
@Nonnull
public static ObjectReader getMappingObjectReader() {
return GitHubClient.getMappingObjectReader(GitHub.offline());
Expand Down
6 changes: 6 additions & 0 deletions src/test/java/org/kohsuke/github/GitHubStaticTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ public void testMappingReaderWriter() throws Exception {
assertThat(readRepo.root, nullValue());
assertThat(readRepo.getResponseHeaderFields(), nullValue());

readRepo = GitHub.getMappingObjectReader().forType(GHRepository.class).readValue(repoString);

// This should never happen if the internal method isn't used
assertThat(readRepo.root.getConnector(), equalTo(HttpConnector.OFFLINE));
assertThat(readRepo.getResponseHeaderFields(), nullValue());

String readRepoString = GitHub.getMappingObjectWriter().writeValueAsString(readRepo);
assertThat(readRepoString, equalTo(repoString));

Expand Down