JndiPropertySource defensively skips invalid JNDI lookup for property name with colon in resource-ref mode

Issue: SPR-14518
This commit is contained in:
Juergen Hoeller
2016-07-27 22:37:25 +02:00
parent 3ab21741f9
commit 328e04f167
2 changed files with 43 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -78,6 +78,15 @@ public class JndiPropertySource extends PropertySource<JndiLocatorDelegate> {
*/
@Override
public Object getProperty(String name) {
if (getSource().isResourceRef() && name.indexOf(':') != -1) {
// We're in resource-ref (prefixing with "java:comp/env") mode. Let's not bother
// with property names with a colon it since they're probably just containing a
// default value clause, very unlikely to match including the colon part even in
// a textual property source, and effectively never meant to match that way in
// JNDI where a colon indicates a separator between JNDI scheme and actual name.
return null;
}
try {
Object value = this.source.lookup(name);
if (logger.isDebugEnabled()) {