Merge pull request #17860 from guanbiaoHuang

* pr/17860:
  Polish "Simplify some code"
  Simplify some code

Closes gh-17860
pull/17864/head
Stephane Nicoll 5 years ago
commit 287caa210b

@ -123,9 +123,7 @@ class RequestPredicateFactory {
} }
if (WebEndpointResponse.class.isAssignableFrom(method.getReturnType())) { if (WebEndpointResponse.class.isAssignableFrom(method.getReturnType())) {
ResolvableType returnType = ResolvableType.forMethodReturnType(method); ResolvableType returnType = ResolvableType.forMethodReturnType(method);
if (ResolvableType.forClass(Resource.class).isAssignableFrom(returnType.getGeneric(0))) { return ResolvableType.forClass(Resource.class).isAssignableFrom(returnType.getGeneric(0));
return true;
}
} }
return false; return false;
} }

@ -89,7 +89,7 @@ public final class Health {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj != null && obj instanceof Health) { if (obj instanceof Health) {
Health other = (Health) obj; Health other = (Health) obj;
return this.status.equals(other.status) && this.details.equals(other.details); return this.status.equals(other.status) && this.details.equals(other.details);
} }

@ -107,7 +107,7 @@ public final class Status {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj != null && obj instanceof Status) { if (obj instanceof Status) {
return ObjectUtils.nullSafeEquals(this.code, ((Status) obj).code); return ObjectUtils.nullSafeEquals(this.code, ((Status) obj).code);
} }
return false; return false;

@ -71,7 +71,7 @@ public final class Info {
if (obj == this) { if (obj == this) {
return true; return true;
} }
if (obj != null && obj instanceof Info) { if (obj instanceof Info) {
Info other = (Info) obj; Info other = (Info) obj;
return this.details.equals(other.details); return this.details.equals(other.details);
} }

@ -83,10 +83,8 @@ class PlainTextThreadDumpFormatter {
LockInfo lockInfo = info.getLockInfo(); LockInfo lockInfo = info.getLockInfo();
if (firstElement && lockInfo != null) { if (firstElement && lockInfo != null) {
if (element.getClassName().equals(Object.class.getName()) && element.getMethodName().equals("wait")) { if (element.getClassName().equals(Object.class.getName()) && element.getMethodName().equals("wait")) {
if (lockInfo != null) {
writer.printf("\t- waiting on %s%n", format(lockInfo)); writer.printf("\t- waiting on %s%n", format(lockInfo));
} }
}
else { else {
String lockOwner = info.getLockOwnerName(); String lockOwner = info.getLockOwnerName();
if (lockOwner != null) { if (lockOwner != null) {

@ -36,7 +36,7 @@ class AuditEventTests {
@Test @Test
void nowEvent() { void nowEvent() {
AuditEvent event = new AuditEvent("phil", "UNKNOWN", Collections.singletonMap("a", (Object) "b")); AuditEvent event = new AuditEvent("phil", "UNKNOWN", Collections.singletonMap("a", "b"));
assertThat(event.getData().get("a")).isEqualTo("b"); assertThat(event.getData().get("a")).isEqualTo("b");
assertThat(event.getType()).isEqualTo("UNKNOWN"); assertThat(event.getType()).isEqualTo("UNKNOWN");
assertThat(event.getPrincipal()).isEqualTo("phil"); assertThat(event.getPrincipal()).isEqualTo("phil");
@ -52,21 +52,21 @@ class AuditEventTests {
@Test @Test
void nullPrincipalIsMappedToEmptyString() { void nullPrincipalIsMappedToEmptyString() {
AuditEvent auditEvent = new AuditEvent(null, "UNKNOWN", Collections.singletonMap("a", (Object) "b")); AuditEvent auditEvent = new AuditEvent(null, "UNKNOWN", Collections.singletonMap("a", "b"));
assertThat(auditEvent.getPrincipal()).isEmpty(); assertThat(auditEvent.getPrincipal()).isEmpty();
} }
@Test @Test
void nullTimestamp() { void nullTimestamp() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> new AuditEvent(null, "phil", "UNKNOWN", Collections.singletonMap("a", (Object) "b"))) .isThrownBy(() -> new AuditEvent(null, "phil", "UNKNOWN", Collections.singletonMap("a", "b")))
.withMessageContaining("Timestamp must not be null"); .withMessageContaining("Timestamp must not be null");
} }
@Test @Test
void nullType() { void nullType() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> new AuditEvent("phil", null, Collections.singletonMap("a", (Object) "b"))) .isThrownBy(() -> new AuditEvent("phil", null, Collections.singletonMap("a", "b")))
.withMessageContaining("Type must not be null"); .withMessageContaining("Type must not be null");
} }

Loading…
Cancel
Save