public <S> void execute(InputLoader<S> inputLoader, InputConverter<S> converter, @Nullable PeriodicUpdater periodicUpdater) {
long count = 0;
- Connection readConnection = null;
+ Connection readConnection = null, writeConnection = null;
Statement stmt = null;
ResultSet rs = null;
- Connection writeConnection = null;
PreparedStatement writeStatement = null;
try {
readConnection = db.getDataSource().getConnection();
DbUtils.closeQuietly(writeStatement);
DbUtils.closeQuietly(writeConnection);
DbUtils.closeQuietly(readConnection, stmt, rs);
-
LOGGER.info("{} rows have been updated", count);
}
}
ActiveRuleChange change;
boolean stopPropagation = false;
- if (context.activeRule() == null) {
+ ActiveRuleDto activeRule = context.activeRule();
+ if (activeRule == null) {
if (activation.isReset()) {
// ignore reset when rule is not activated
return changes;
}
} else {
// already activated
- if (activation.isCascade() && context.activeRule().doesOverride()) {
+ if (activation.isCascade() && activeRule.doesOverride()) {
// propagating to descendants, but child profile already overrides rule -> stop propagation
return changes;
}
change = ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, context.activeRuleKey());
- if (activation.isCascade() && context.activeRule().getInheritance() == null) {
+ if (activation.isCascade() && activeRule.getInheritance() == null) {
// activate on child, then on parent -> mark child as overriding parent
change.setInheritance(ActiveRule.Inheritance.OVERRIDES);
change.setSeverity(context.currentSeverity());
ActiveRuleDto activeRule;
ActiveRuleDao dao = db.activeRuleDao();
activeRule = context.activeRule();
- activeRule.setSeverity(change.getSeverity());
- if (change.getInheritance() != null) {
- activeRule.setInheritance(change.getInheritance().name());
+ String severity = change.getSeverity();
+ if (severity != null) {
+ activeRule.setSeverity(severity);
+ }
+ ActiveRule.Inheritance inheritance = change.getInheritance();
+ if (inheritance != null) {
+ activeRule.setInheritance(inheritance.name());
}
dao.update(dbSession, activeRule);
// unset if parent is defined, else nothing to do
removeParent(dbSession, profile);
- } else if (profile.getParentKee() == null || !profile.getParentKee().equals(parentKey)) {
+ } else if (profile.getParentKee() == null || !parentKey.equals(profile.getParentKee())) {
QualityProfileDto parentProfile = db.qualityProfileDao().getNonNullByKey(dbSession, parentKey);
if (isDescendant(dbSession, profile, parentProfile)) {
throw new BadRequestException(String.format("Descendant profile '%s' can not be selected as parent of '%s'", parentKey, profileKey));
if (childProfile.getName().equals(currentParent.getName())) {
return true;
}
- if (currentParent.getParentKee() != null) {
- currentParent = db.qualityProfileDao().getByKey(dbSession, currentParent.getParentKee());
+ String parentKey = currentParent.getParentKee();
+ if (parentKey != null) {
+ currentParent = db.qualityProfileDao().getByKey(dbSession, parentKey);
} else {
currentParent = null;
}