Browse Source

SONAR-20864 Reset grace period when setting new license.

tags/9.9.3.79811
Wojtek Wajerowicz 7 months ago
parent
commit
dc731234d9

+ 6
- 0
server/sonar-server-common/src/main/java/org/sonar/server/property/InternalProperties.java View File

* @throws IllegalArgumentException if {@code propertyKey} is {@code null} or empty * @throws IllegalArgumentException if {@code propertyKey} is {@code null} or empty
*/ */
void write(String propertyKey, @Nullable String value); void write(String propertyKey, @Nullable String value);

/**
* Delete the specified property.
*
*/
void delete(String propertyKey);
} }

+ 9
- 0
server/sonar-server-common/src/main/java/org/sonar/server/property/InternalPropertiesImpl.java View File

} }
} }


@Override
public void delete(String propertyKey) {
checkPropertyKey(propertyKey);
try (DbSession dbSession = dbClient.openSession(false)) {
dbClient.internalPropertiesDao().delete(dbSession, propertyKey);
dbSession.commit();
}
}

private static void checkPropertyKey(@Nullable String propertyKey) { private static void checkPropertyKey(@Nullable String propertyKey) {
checkArgument(propertyKey != null && !propertyKey.isEmpty(), "property key can't be null nor empty"); checkArgument(propertyKey != null && !propertyKey.isEmpty(), "property key can't be null nor empty");
} }

+ 6
- 0
server/sonar-server-common/src/main/java/org/sonar/server/property/MapInternalProperties.java View File

values.put(propertyKey, value); values.put(propertyKey, value);
} }


@Override
public void delete(String propertyKey) {
checkPropertyKey(propertyKey);
values.remove(propertyKey);
}

private static void checkPropertyKey(@Nullable String propertyKey) { private static void checkPropertyKey(@Nullable String propertyKey) {
checkArgument(propertyKey != null && !propertyKey.isEmpty(), "property key can't be null nor empty"); checkArgument(propertyKey != null && !propertyKey.isEmpty(), "property key can't be null nor empty");
} }

+ 7
- 0
server/sonar-server-common/src/test/java/org/sonar/server/property/InternalPropertiesImplTest.java View File

verify(dbSession).commit(); verify(dbSession).commit();
} }


@Test
public void delete_shouldCallDaoAndDeleteProperty() {
underTest.delete(SOME_KEY);
verify(internalPropertiesDao).delete(dbSession, SOME_KEY);
verify(dbSession).commit();
}

private void expectKeyNullOrEmptyIAE(ThrowingCallable callback) { private void expectKeyNullOrEmptyIAE(ThrowingCallable callback) {
assertThatThrownBy(callback) assertThatThrownBy(callback)
.isInstanceOf(IllegalArgumentException.class) .isInstanceOf(IllegalArgumentException.class)

Loading…
Cancel
Save