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

Add API to retrive all topic related data from the change #77

Merged
merged 4 commits into from
Feb 15, 2018

Conversation

Jimilian
Copy link
Contributor

@Jimilian Jimilian commented Feb 6, 2018

Also adds change status to the change based events.

*/
private String topic;
private Topic topic;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous as old serialized data will fail to load (for example old build records in Jenkins).
The old field unfortunately needs to stay.
You can mark it as transient so that new objects won't serialize the data. And add a readResolve method to convert the old field to the new one if possible.

* @param topic the topic.
*/
public void setTopic(String topic) {
public void setTopic(Topic topic) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breaking binary backwards compatibility.

@@ -41,7 +42,7 @@
/**
* The previous topic value. New topic is in change.topic.
*/
private String oldTopic;
private Topic oldTopic;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dito

*/
@Deprecated
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the rational of moving this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be able to query list of files outside of ChangeBasedEvent. i.e.

for(Change change : change.getTopic().getChanges()) {
     List<String> files = change.getFiles(gerritQueryHandler);
    // do something with this files
}

@Jimilian Jimilian force-pushed the native_topic branch 3 times, most recently from 42a23d4 to 1cadefe Compare February 8, 2018 16:46
@Jimilian
Copy link
Contributor Author

Jimilian commented Feb 8, 2018

@rsandell Done. Please take a look.

Also adds change status to the change based events.
*/
UNKNOWN("UNKNOWN");

private final String status;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit The status is a bit redundant since GerritChangeStatus.name() will give the same value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you are right

/**
* The changed files in this patchset.
*/
private List<String> files;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I missed this one before, but this is also where old data will fail to serialize, so you need to do something similar to Topic. I.e. keep the old field but make it transient and add a readResolve that'll move the files into Change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

*/
public Map<Change, PatchSet> getChanges(GerritQueryHandler gerritQueryHandler) {
if (changes == null) {
changes = new HashMap<Change, PatchSet>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If something fails below, you will end up with an empty change list in this topic "forever" And will not be able to retrieve them on a second try.

@Jimilian
Copy link
Contributor Author

@rsandell Done. This time I tried to simplify review as much as possible :)

Copy link
Collaborator

@rsandell rsandell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more thing I hope :/

}
}
return files;
return change.getFiles(gerritQueryHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the old behavior has changed in FileHelper.getFilesByChange (it now returns null instead of an empty list), just to be safe I think we need to preserve the old behavior here. E.g. if returned == null { return Collections.emptyList() }

@Jimilian
Copy link
Contributor Author

All your points were valid. So, I'm completely fine to fix it :)

Last change is amended.

@rsandell rsandell merged commit 5d79b32 into sonyxperiadev:master Feb 15, 2018
@Jimilian Jimilian deleted the native_topic branch February 15, 2018 15:45
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

Successfully merging this pull request may close these issues.

2 participants