Skip to content

Commit

Permalink
Improve condition for returning type and avoiding NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocnhan-tran1996 committed Oct 15, 2024
1 parent 6fe2d10 commit ee578d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -30,6 +30,7 @@
* @author Mark Fisher
* @author Dave Syer
* @author Gary Russell
* @author Ngoc Nhan
*
* @see AmqpAdmin
*/
Expand Down Expand Up @@ -74,7 +75,7 @@ public Binding(@Nullable Queue lazyQueue, @Nullable String destination, Destinat
String exchange, @Nullable String routingKey, @Nullable Map<String, Object> arguments) {

super(arguments);
Assert.isTrue(lazyQueue == null || destinationType.equals(DestinationType.QUEUE),
Assert.isTrue(lazyQueue == null || destinationType == DestinationType.QUEUE,
"'lazyQueue' must be null for destination type " + destinationType);
Assert.isTrue(lazyQueue != null || destination != null, "`destination` cannot be null");
this.lazyQueue = lazyQueue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ protected String retrieveHeader(MessageProperties properties, String headerName)
protected String retrieveHeaderAsString(MessageProperties properties, String headerName) {
Map<String, Object> headers = properties.getHeaders();
Object classIdFieldNameValue = headers.get(headerName);
String classId = null;
if (classIdFieldNameValue != null) {
classId = classIdFieldNameValue.toString();
}
return classId;
return classIdFieldNameValue != null
? classIdFieldNameValue.toString()
: null;
}

private void createReverseMap() {
Expand Down

0 comments on commit ee578d8

Please sign in to comment.