Skip to content

Commit f527025

Browse files
committed
Fix placeholder in JmsChannelParser for cache
Looks like spring JMS does not uppercase the `cacheLevelName` before assigning anymore. * Remove `toUpperCase()` for `cache` in the `JmsChannelParser` logic. * Perform `toUpperCase()` in the `JmsChannelFactoryBean.setCacheLevelName()` instead
1 parent 20d5f62 commit f527025

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelFactoryBean.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -203,9 +203,10 @@ public void setAutoStartup(boolean autoStartup) {
203203
}
204204

205205
public void setCacheLevelName(String cacheLevelName) {
206+
Assert.hasText(cacheLevelName, "The 'cacheLevelName' must not be empty");
206207
Assert.isTrue(this.messageDriven, "'cacheLevelName' is allowed only in case of 'messageDriven = true'");
207208
Assert.state(this.cacheLevel == null, "'cacheLevelName' and 'cacheLevel' are mutually exclusive");
208-
this.cacheLevelName = cacheLevelName;
209+
this.cacheLevelName = cacheLevelName.toUpperCase();
209210
}
210211

211212
public void setCacheLevel(Integer cacheLevel) {

spring-integration-jms/src/main/java/org/springframework/integration/jms/config/JmsChannelParser.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,8 @@
2323
import org.springframework.beans.factory.xml.ParserContext;
2424
import org.springframework.integration.config.xml.AbstractChannelParser;
2525
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
26+
import org.springframework.jms.listener.DefaultMessageListenerContainer;
27+
import org.springframework.jms.listener.SimpleMessageListenerContainer;
2628
import org.springframework.util.StringUtils;
2729

2830
/**
@@ -119,10 +121,10 @@ private static void setContainerClass(Element element, BeanDefinitionBuilder bui
119121
String containerClass = element.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
120122
if (!StringUtils.hasText(containerClass) && StringUtils.hasText(containerType)) {
121123
if ("default".equals(containerType)) {
122-
containerClass = "org.springframework.jms.listener.DefaultMessageListenerContainer";
124+
containerClass = DefaultMessageListenerContainer.class.getName();
123125
}
124126
else if ("simple".equals(containerType)) {
125-
containerClass = "org.springframework.jms.listener.SimpleMessageListenerContainer";
127+
containerClass = SimpleMessageListenerContainer.class.getName();
126128
}
127129
}
128130
/*
@@ -151,7 +153,7 @@ private static void setCache(Element element, ParserContext parserContext, BeanD
151153
}
152154
}
153155
else {
154-
builder.addPropertyValue("cacheLevelName", "CACHE_" + cache.toUpperCase());
156+
builder.addPropertyValue("cacheLevelName", "CACHE_" + cache);
155157
}
156158
}
157159
}

0 commit comments

Comments
 (0)