Skip to content

Commit 484a2f3

Browse files
committed
Polishing
1 parent 5bd5df3 commit 484a2f3

File tree

12 files changed

+79
-99
lines changed

12 files changed

+79
-99
lines changed

spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -17,6 +17,7 @@
1717
package org.springframework.cache.jcache;
1818

1919
import java.util.concurrent.Callable;
20+
import javax.cache.Cache;
2021
import javax.cache.processor.EntryProcessor;
2122
import javax.cache.processor.EntryProcessorException;
2223
import javax.cache.processor.MutableEntry;
@@ -36,14 +37,14 @@
3637
*/
3738
public class JCacheCache extends AbstractValueAdaptingCache {
3839

39-
private final javax.cache.Cache<Object, Object> cache;
40+
private final Cache<Object, Object> cache;
4041

4142

4243
/**
4344
* Create an {@link org.springframework.cache.jcache.JCacheCache} instance.
4445
* @param jcache backing JCache Cache instance
4546
*/
46-
public JCacheCache(javax.cache.Cache<Object, Object> jcache) {
47+
public JCacheCache(Cache<Object, Object> jcache) {
4748
this(jcache, true);
4849
}
4950

@@ -52,7 +53,7 @@ public JCacheCache(javax.cache.Cache<Object, Object> jcache) {
5253
* @param jcache backing JCache Cache instance
5354
* @param allowNullValues whether to accept and convert null values for this cache
5455
*/
55-
public JCacheCache(javax.cache.Cache<Object, Object> jcache, boolean allowNullValues) {
56+
public JCacheCache(Cache<Object, Object> jcache, boolean allowNullValues) {
5657
super(allowNullValues);
5758
Assert.notNull(jcache, "Cache must not be null");
5859
this.cache = jcache;
@@ -65,7 +66,7 @@ public final String getName() {
6566
}
6667

6768
@Override
68-
public final javax.cache.Cache<Object, Object> getNativeCache() {
69+
public final Cache<Object, Object> getNativeCache() {
6970
return this.cache;
7071
}
7172

spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2017 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.
@@ -36,7 +36,7 @@
3636
*/
3737
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
3838

39-
private javax.cache.CacheManager cacheManager;
39+
private CacheManager cacheManager;
4040

4141
private boolean allowNullValues = true;
4242

@@ -60,14 +60,14 @@ public JCacheCacheManager(CacheManager cacheManager) {
6060
/**
6161
* Set the backing JCache {@link javax.cache.CacheManager}.
6262
*/
63-
public void setCacheManager(javax.cache.CacheManager cacheManager) {
63+
public void setCacheManager(CacheManager cacheManager) {
6464
this.cacheManager = cacheManager;
6565
}
6666

6767
/**
6868
* Return the backing JCache {@link javax.cache.CacheManager}.
6969
*/
70-
public javax.cache.CacheManager getCacheManager() {
70+
public CacheManager getCacheManager() {
7171
return this.cacheManager;
7272
}
7373

spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -58,7 +58,7 @@ public Collection<CacheOperation> parseCacheAnnotations(Method method) {
5858
return parseCacheAnnotations(defaultConfig, method);
5959
}
6060

61-
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
61+
private Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
6262
Collection<CacheOperation> ops = null;
6363

6464
Collection<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class);
@@ -68,20 +68,23 @@ protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig ca
6868
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
6969
}
7070
}
71+
7172
Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class);
7273
if (!evicts.isEmpty()) {
7374
ops = lazyInit(ops);
7475
for (CacheEvict evict : evicts) {
7576
ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
7677
}
7778
}
79+
7880
Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class);
7981
if (!puts.isEmpty()) {
8082
ops = lazyInit(ops);
8183
for (CachePut put : puts) {
8284
ops.add(parsePutAnnotation(ae, cachingConfig, put));
8385
}
8486
}
87+
8588
Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class);
8689
if (!cachings.isEmpty()) {
8790
ops = lazyInit(ops);
@@ -283,7 +286,6 @@ else if (StringUtils.hasText(this.cacheManager)) {
283286
builder.setCacheManager(this.cacheManager);
284287
}
285288
}
286-
287289
}
288290

289291
}

spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -145,7 +145,7 @@ public final void parse(InputSource ignored) throws SAXException {
145145
* Parse the StAX XML reader passed at construction-time.
146146
* <p><b>NOTE:</b>: The given system identifier is not read, but ignored.
147147
* @param ignored is ignored
148-
* @throws SAXException A SAX exception, possibly wrapping a {@code XMLStreamException}
148+
* @throws SAXException a SAX exception, possibly wrapping a {@code XMLStreamException}
149149
*/
150150
@Override
151151
public final void parse(String ignored) throws SAXException {
@@ -182,13 +182,10 @@ private void parse() throws SAXException {
182182
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
183183
*/
184184
protected void startPrefixMapping(String prefix, String namespace) throws SAXException {
185-
if (getContentHandler() != null) {
185+
if (getContentHandler() != null && StringUtils.hasLength(namespace)) {
186186
if (prefix == null) {
187187
prefix = "";
188188
}
189-
if (!StringUtils.hasLength(namespace)) {
190-
return;
191-
}
192189
if (!namespace.equals(this.namespaces.get(prefix))) {
193190
getContentHandler().startPrefixMapping(prefix, namespace);
194191
this.namespaces.put(prefix, namespace);
@@ -201,11 +198,9 @@ protected void startPrefixMapping(String prefix, String namespace) throws SAXExc
201198
* @see org.xml.sax.ContentHandler#endPrefixMapping(String)
202199
*/
203200
protected void endPrefixMapping(String prefix) throws SAXException {
204-
if (getContentHandler() != null) {
205-
if (this.namespaces.containsKey(prefix)) {
206-
getContentHandler().endPrefixMapping(prefix);
207-
this.namespaces.remove(prefix);
208-
}
201+
if (getContentHandler() != null && this.namespaces.containsKey(prefix)) {
202+
getContentHandler().endPrefixMapping(prefix);
203+
this.namespaces.remove(prefix);
209204
}
210205
}
211206

spring-core/src/main/java/org/springframework/util/xml/AbstractXMLStreamReader.java

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -21,8 +21,6 @@
2121
import javax.xml.stream.XMLStreamException;
2222
import javax.xml.stream.XMLStreamReader;
2323

24-
import org.springframework.util.Assert;
25-
2624
/**
2725
* Abstract base class for {@code XMLStreamReader}s.
2826
*
@@ -34,7 +32,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
3432
@Override
3533
public String getElementText() throws XMLStreamException {
3634
if (getEventType() != XMLStreamConstants.START_ELEMENT) {
37-
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", getLocation());
35+
throw new XMLStreamException("Parser must be on START_ELEMENT to read next text", getLocation());
3836
}
3937
int eventType = next();
4038
StringBuilder builder = new StringBuilder();
@@ -48,11 +46,11 @@ else if (eventType == XMLStreamConstants.PROCESSING_INSTRUCTION ||
4846
// skipping
4947
}
5048
else if (eventType == XMLStreamConstants.END_DOCUMENT) {
51-
throw new XMLStreamException("unexpected end of document when reading element text content",
49+
throw new XMLStreamException("Unexpected end of document when reading element text content",
5250
getLocation());
5351
}
5452
else if (eventType == XMLStreamConstants.START_ELEMENT) {
55-
throw new XMLStreamException("element text content may not contain START_ELEMENT", getLocation());
53+
throw new XMLStreamException("Element text content may not contain START_ELEMENT", getLocation());
5654
}
5755
else {
5856
throw new XMLStreamException("Unexpected event type " + eventType, getLocation());
@@ -84,22 +82,21 @@ public String getNamespaceURI() {
8482
return getName().getNamespaceURI();
8583
}
8684
else {
87-
throw new IllegalStateException("parser must be on START_ELEMENT or END_ELEMENT state");
85+
throw new IllegalStateException("Parser must be on START_ELEMENT or END_ELEMENT state");
8886
}
8987
}
9088

9189
@Override
9290
public String getNamespaceURI(String prefix) {
93-
Assert.notNull(prefix, "No prefix given");
9491
return getNamespaceContext().getNamespaceURI(prefix);
9592
}
9693

9794
@Override
9895
public boolean hasText() {
9996
int eventType = getEventType();
100-
return eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.CHARACTERS ||
97+
return (eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.CHARACTERS ||
10198
eventType == XMLStreamConstants.COMMENT || eventType == XMLStreamConstants.CDATA ||
102-
eventType == XMLStreamConstants.ENTITY_REFERENCE;
99+
eventType == XMLStreamConstants.ENTITY_REFERENCE);
103100
}
104101

105102
@Override
@@ -109,14 +106,14 @@ public String getPrefix() {
109106
return getName().getPrefix();
110107
}
111108
else {
112-
throw new IllegalStateException("parser must be on START_ELEMENT or END_ELEMENT state");
109+
throw new IllegalStateException("Parser must be on START_ELEMENT or END_ELEMENT state");
113110
}
114111
}
115112

116113
@Override
117114
public boolean hasName() {
118115
int eventType = getEventType();
119-
return eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT;
116+
return (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT);
120117
}
121118

122119
@Override
@@ -174,7 +171,7 @@ public String getAttributeValue(String namespaceURI, String localName) {
174171
}
175172

176173
@Override
177-
public boolean hasNext() throws XMLStreamException {
174+
public boolean hasNext() {
178175
return getEventType() != END_DOCUMENT;
179176
}
180177

@@ -189,8 +186,7 @@ public char[] getTextCharacters() {
189186
}
190187

191188
@Override
192-
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
193-
throws XMLStreamException {
189+
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) {
194190
char[] source = getTextCharacters();
195191
length = Math.min(length, source.length);
196192
System.arraycopy(source, sourceStart, target, targetStart, length);
@@ -201,4 +197,5 @@ public int getTextCharacters(int sourceStart, char[] target, int targetStart, in
201197
public int getTextLength() {
202198
return getText().length();
203199
}
200+
204201
}

0 commit comments

Comments
 (0)