Skip to content

Commit

Permalink
Fix potential NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 30, 2023
1 parent 99b9b64 commit ab2a6cb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public ManagedConnectionFactory createManagedConnectionFactory(ResourceAdapter a
@Override
public ActivationSpec createActivationSpec(ResourceAdapter adapter, Class<?> type, Map<String, String> config)
throws ResourceException {
//TODO: Use the config
ActiveMQActivationSpec activationSpec = new ActiveMQActivationSpec();
activationSpec.setResourceAdapter(adapter);
activationSpec.setDestinationType(config.get("destination-type"));
activationSpec.setDestination(config.get("destination"));
activationSpec.setMaxSession(Integer.valueOf(config.getOrDefault("max-session", "2")));
activationSpec.setMaxSession(Integer.valueOf(config.getOrDefault("max-session", "5")));
activationSpec.setRebalanceConnections(Boolean.valueOf(config.getOrDefault("rebalance-connections", "true")));
activationSpec.setUseJNDI(false);
activationSpec.setUseLocalTx(false);
return activationSpec;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class MyMessageEndpoint implements MessageListener {
@Transactional(Transactional.TxType.REQUIRES_NEW)
public void onMessage(Message message) {
try {
Log.infof("Redelivered: %s",message.getJMSRedelivered());
Log.infof("Transaction is Active? %s", QuarkusTransaction.isActive());
String body = message.getBody(String.class);
Log.infof("Received message: %s", body);
Expand Down
13 changes: 13 additions & 0 deletions integration-tests/artemis-jms/src/test/resources/broker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,18 @@

<max-disk-usage>-1</max-disk-usage>
<security-enabled>false</security-enabled>
<addresses>
<address name="MyQueue">
<anycast>
<queue name="MyQueue"/>
</anycast>
</address>
</addresses>
<address-settings>
<address-setting match="MyQueue">
<dead-letter-address>MyQueueDLQ</dead-letter-address>
<expiry-address>MyQueueExpiry</expiry-address>
</address-setting>
</address-settings>
</core>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public void activateEndpoint(String containerId, String activationSpecConfigId,
throw new RuntimeException(e);
}
Map<String, String> config = new HashMap<>(buildTimeConfig);
// TODO: May throw NPE?
config.putAll(this.runtimeConfig.activationSpecs().map().get(activationSpecConfigId).config());
var activationSpecConfig = runtimeConfig.activationSpecs().map().get(activationSpecConfigId);
if (activationSpecConfig != null) {
config.putAll(activationSpecConfig.config());
}
try {
ijContainer.endpointActivation(endpointClass, containerId, config);
} catch (ResourceException e) {
Expand Down

0 comments on commit ab2a6cb

Please sign in to comment.