Remove inconsistent null value checkings in the ChangeEmail class
Variable ChangeEmail.change is used widely in sending change emails, sometimes its value is tested to see if it is null, sometimes it is not tested, we just remove the null value checking for all places, and let the users of ChangeEmail class to make sure to pass a valid value. Change-Id: I26b2d1c2f84e632603b74e5a680b72c922ead3e3
This commit is contained in:
@@ -81,7 +81,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
final Change c, final String mc) {
|
final Change c, final String mc) {
|
||||||
super(ea, anonymousCowardName, mc);
|
super(ea, anonymousCowardName, mc);
|
||||||
change = c;
|
change = c;
|
||||||
changeData = change != null ? new ChangeData(change) : null;
|
changeData = new ChangeData(change);
|
||||||
emailOnlyAuthors = false;
|
emailOnlyAuthors = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
|
|
||||||
/** Get a link to the change; null if the server doesn't know its own address. */
|
/** Get a link to the change; null if the server doesn't know its own address. */
|
||||||
public String getChangeUrl() {
|
public String getChangeUrl() {
|
||||||
if (change != null && getGerritUrl() != null) {
|
if (getGerritUrl() != null) {
|
||||||
final StringBuilder r = new StringBuilder();
|
final StringBuilder r = new StringBuilder();
|
||||||
r.append(getGerritUrl());
|
r.append(getGerritUrl());
|
||||||
r.append(change.getChangeId());
|
r.append(change.getChangeId());
|
||||||
@@ -356,10 +356,6 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
/** Returns all watches that are relevant */
|
/** Returns all watches that are relevant */
|
||||||
protected final Watchers getWatches(NotifyType type) throws OrmException {
|
protected final Watchers getWatches(NotifyType type) throws OrmException {
|
||||||
Watchers matching = new Watchers();
|
Watchers matching = new Watchers();
|
||||||
if (changeData == null) {
|
|
||||||
return matching;
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<Account.Id> projectWatchers = new HashSet<Account.Id>();
|
Set<Account.Id> projectWatchers = new HashSet<Account.Id>();
|
||||||
|
|
||||||
for (AccountProjectWatch w : args.db.get().accountProjectWatches()
|
for (AccountProjectWatch w : args.db.get().accountProjectWatches()
|
||||||
@@ -545,7 +541,6 @@ public abstract class ChangeEmail extends OutgoingEmail {
|
|||||||
|
|
||||||
protected boolean isVisibleTo(final Account.Id to) throws OrmException {
|
protected boolean isVisibleTo(final Account.Id to) throws OrmException {
|
||||||
return projectState == null
|
return projectState == null
|
||||||
|| change == null
|
|
||||||
|| projectState.controlFor(args.identifiedUserFactory.create(to))
|
|| projectState.controlFor(args.identifiedUserFactory.create(to))
|
||||||
.controlFor(change).isVisible(args.db.get());
|
.controlFor(change).isVisible(args.db.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ public class CreateChangeSender extends NewChangeSender {
|
|||||||
|
|
||||||
private boolean isOwnerOfProjectOrBranch(Account.Id user) {
|
private boolean isOwnerOfProjectOrBranch(Account.Id user) {
|
||||||
return projectState != null
|
return projectState != null
|
||||||
&& change != null
|
|
||||||
&& projectState.controlFor(args.identifiedUserFactory.create(user))
|
&& projectState.controlFor(args.identifiedUserFactory.create(user))
|
||||||
.controlForRef(change.getDest())
|
.controlForRef(change.getDest())
|
||||||
.isOwner();
|
.isOwner();
|
||||||
|
|||||||
Reference in New Issue
Block a user