Browse Source

Polishing

pull/35672/head
Juergen Hoeller 2 months ago
parent
commit
c53132ecdf
  1. 1
      spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessor.java
  2. 2
      spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java
  3. 2
      spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java
  4. 1
      spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringConstraintValidatorFactory.java
  5. 2
      spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java
  6. 85
      spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java
  7. 1
      spring-web/src/main/java/org/springframework/web/bind/support/SpringWebConstraintValidatorFactory.java
  8. 7
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java

1
spring-context/src/main/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessor.java

@ -87,7 +87,6 @@ public class AsyncAnnotationBeanPostProcessor extends AbstractBeanFactoryAwareAd
private Class<? extends Annotation> asyncAnnotationType; private Class<? extends Annotation> asyncAnnotationType;
public AsyncAnnotationBeanPostProcessor() { public AsyncAnnotationBeanPostProcessor() {
setBeforeExistingAdvisors(true); setBeforeExistingAdvisors(true);
} }

2
spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationInterceptor.java

@ -69,8 +69,6 @@ import org.springframework.validation.method.ParameterValidationResult;
* at the type level of the containing target class, applying to all public service methods * at the type level of the containing target class, applying to all public service methods
* of that class. By default, JSR-303 will validate against its default group only. * of that class. By default, JSR-303 will validate against its default group only.
* *
* <p>This functionality requires a Bean Validation 1.1+ provider.
*
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Rossen Stoyanchev * @author Rossen Stoyanchev
* @since 3.1 * @since 3.1

2
spring-context/src/main/java/org/springframework/validation/beanvalidation/MethodValidationPostProcessor.java

@ -60,8 +60,6 @@ import org.springframework.validation.method.MethodValidationResult;
* inline constraint annotations. Validation groups can be specified through {@code @Validated} * inline constraint annotations. Validation groups can be specified through {@code @Validated}
* as well. By default, JSR-303 will validate against its default group only. * as well. By default, JSR-303 will validate against its default group only.
* *
* <p>This functionality requires a Bean Validation 1.1+ provider.
*
* @author Juergen Hoeller * @author Juergen Hoeller
* @since 3.1 * @since 3.1
* @see MethodValidationInterceptor * @see MethodValidationInterceptor

1
spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringConstraintValidatorFactory.java

@ -56,7 +56,6 @@ public class SpringConstraintValidatorFactory implements ConstraintValidatorFact
return this.beanFactory.createBean(key); return this.beanFactory.createBean(key);
} }
// Bean Validation 1.1 releaseInstance method
@Override @Override
public void releaseInstance(ConstraintValidator<?, ?> instance) { public void releaseInstance(ConstraintValidator<?, ?> instance) {
this.beanFactory.destroyBean(instance); this.beanFactory.destroyBean(instance);

2
spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java

@ -55,8 +55,6 @@ import org.springframework.validation.SmartValidator;
* {@link CustomValidatorBean} and {@link LocalValidatorFactoryBean}, * {@link CustomValidatorBean} and {@link LocalValidatorFactoryBean},
* and as the primary implementation of the {@link SmartValidator} interface. * and as the primary implementation of the {@link SmartValidator} interface.
* *
* <p>This adapter is fully compatible with Bean Validation 1.1 as well as 2.0.
*
* @author Juergen Hoeller * @author Juergen Hoeller
* @author Sam Brannen * @author Sam Brannen
* @since 3.0 * @since 3.0

85
spring-core/src/main/java/org/springframework/core/io/buffer/DataBuffer.java

@ -36,8 +36,9 @@ import org.springframework.util.Assert;
* <p>{@code DataBuffer}s has a separate {@linkplain #readPosition() read} and * <p>{@code DataBuffer}s has a separate {@linkplain #readPosition() read} and
* {@linkplain #writePosition() write} position, as opposed to {@code ByteBuffer}'s * {@linkplain #writePosition() write} position, as opposed to {@code ByteBuffer}'s
* single {@linkplain ByteBuffer#position() position}. As such, the {@code DataBuffer} * single {@linkplain ByteBuffer#position() position}. As such, the {@code DataBuffer}
* does not require a {@linkplain ByteBuffer#flip() flip} to read after writing. In general, * does not require a {@linkplain ByteBuffer#flip() flip} to read after writing.
* the following invariant holds for the read and write positions, and the capacity: * In general, the following invariant holds for the read and write positions,
* and the capacity:
* *
* <blockquote> * <blockquote>
* {@code 0} {@code <=} * {@code 0} {@code <=}
@ -46,12 +47,13 @@ import org.springframework.util.Assert;
* <i>capacity</i> * <i>capacity</i>
* </blockquote> * </blockquote>
* *
* <p>The {@linkplain #capacity() capacity} of a {@code DataBuffer} is expanded on demand, * <p>The {@linkplain #capacity() capacity} of a {@code DataBuffer} is expanded on
* similar to {@code StringBuilder}. * demand, similar to {@code StringBuilder}.
* *
* <p>The main purpose of the {@code DataBuffer} abstraction is to provide a convenient wrapper * <p>The main purpose of the {@code DataBuffer} abstraction is to provide a
* around {@link ByteBuffer} which is similar to Netty's {@link io.netty.buffer.ByteBuf} but * convenient wrapper around {@link ByteBuffer} which is similar to Netty's
* can also be used on non-Netty platforms (i.e. Servlet containers). * {@link io.netty.buffer.ByteBuf} but can also be used on non-Netty platforms
* (i.e. Servlet containers).
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @author Brian Clozel * @author Brian Clozel
@ -113,8 +115,8 @@ public interface DataBuffer {
* the current capacity, it will be expanded. * the current capacity, it will be expanded.
* @param capacity the new capacity * @param capacity the new capacity
* @return this buffer * @return this buffer
* @deprecated as of 6.0, in favor of {@link #ensureWritable(int)}, which * @deprecated as of 6.0, in favor of {@link #ensureWritable(int)}
* has different semantics * which has different semantics
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
DataBuffer capacity(int capacity); DataBuffer capacity(int capacity);
@ -240,16 +242,16 @@ public interface DataBuffer {
DataBuffer write(byte b); DataBuffer write(byte b);
/** /**
* Write the given source into this buffer, starting at the current writing position * Write the given source into this buffer, starting at the current writing
* of this buffer. * position of this buffer.
* @param source the bytes to be written into this buffer * @param source the bytes to be written into this buffer
* @return this buffer * @return this buffer
*/ */
DataBuffer write(byte[] source); DataBuffer write(byte[] source);
/** /**
* Write at most {@code length} bytes of the given source into this buffer, starting * Write at most {@code length} bytes of the given source into this buffer,
* at the current writing position of this buffer. * starting at the current writing position of this buffer.
* @param source the bytes to be written into this buffer * @param source the bytes to be written into this buffer
* @param offset the index within {@code source} to start writing from * @param offset the index within {@code source} to start writing from
* @param length the maximum number of bytes to be written from {@code source} * @param length the maximum number of bytes to be written from {@code source}
@ -258,8 +260,8 @@ public interface DataBuffer {
DataBuffer write(byte[] source, int offset, int length); DataBuffer write(byte[] source, int offset, int length);
/** /**
* Write one or more {@code DataBuffer}s to this buffer, starting at the current * Write one or more {@code DataBuffer}s to this buffer, starting at the
* writing position. It is the responsibility of the caller to * current writing position. It is the responsibility of the caller to
* {@linkplain DataBufferUtils#release(DataBuffer) release} the given data buffers. * {@linkplain DataBufferUtils#release(DataBuffer) release} the given data buffers.
* @param buffers the byte buffers to write into this buffer * @param buffers the byte buffers to write into this buffer
* @return this buffer * @return this buffer
@ -267,8 +269,8 @@ public interface DataBuffer {
DataBuffer write(DataBuffer... buffers); DataBuffer write(DataBuffer... buffers);
/** /**
* Write one or more {@link ByteBuffer} to this buffer, starting at the current * Write one or more {@link ByteBuffer} to this buffer, starting at the
* writing position. * current writing position.
* @param buffers the byte buffers to write into this buffer * @param buffers the byte buffers to write into this buffer
* @return this buffer * @return this buffer
*/ */
@ -321,36 +323,37 @@ public interface DataBuffer {
} }
/** /**
* Create a new {@code DataBuffer} whose contents is a shared subsequence of this * Create a new {@code DataBuffer} whose contents is a shared subsequence
* data buffer's content. Data between this data buffer and the returned buffer is * of this data buffer's content. Data between this data buffer and the
* shared; though changes in the returned buffer's position will not be reflected * returned buffer is shared; though changes in the returned buffer's
* in the reading nor writing position of this data buffer. * position will not be reflected in the reading nor writing position
* of this data buffer.
* <p><strong>Note</strong> that this method will <strong>not</strong> call * <p><strong>Note</strong> that this method will <strong>not</strong> call
* {@link DataBufferUtils#retain(DataBuffer)} on the resulting slice: the reference * {@link DataBufferUtils#retain(DataBuffer)} on the resulting slice:
* count will not be increased. * the reference count will not be increased.
* @param index the index at which to start the slice * @param index the index at which to start the slice
* @param length the length of the slice * @param length the length of the slice
* @return the specified slice of this data buffer * @return the specified slice of this data buffer
* @deprecated as of 6.0, in favor of {@link #split(int)}, which * @deprecated as of 6.0, in favor of {@link #split(int)}
* has different semantics * which has different semantics
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
DataBuffer slice(int index, int length); DataBuffer slice(int index, int length);
/** /**
* Create a new {@code DataBuffer} whose contents is a shared, retained subsequence of this * Create a new {@code DataBuffer} whose contents is a shared, retained subsequence
* data buffer's content. Data between this data buffer and the returned buffer is * of this data buffer's content. Data between this data buffer and the returned
* shared; though changes in the returned buffer's position will not be reflected * buffer is shared; though changes in the returned buffer's position will not be
* in the reading nor writing position of this data buffer. * reflected in the reading nor writing position of this data buffer.
* <p><strong>Note</strong> that unlike {@link #slice(int, int)}, this method * <p><strong>Note</strong> that unlike {@link #slice(int, int)}, this method
* <strong>will</strong> call {@link DataBufferUtils#retain(DataBuffer)} (or equivalent) on the * <strong>will</strong> call {@link DataBufferUtils#retain(DataBuffer)}
* resulting slice. * (or equivalent) on the resulting slice.
* @param index the index at which to start the slice * @param index the index at which to start the slice
* @param length the length of the slice * @param length the length of the slice
* @return the specified, retained slice of this data buffer * @return the specified, retained slice of this data buffer
* @since 5.2 * @since 5.2
* @deprecated as of 6.0, in favor of {@link #split(int)}, which * @deprecated as of 6.0, in favor of {@link #split(int)}
* has different semantics * which has different semantics
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
default DataBuffer retainedSlice(int index, int length) { default DataBuffer retainedSlice(int index, int length) {
@ -359,12 +362,10 @@ public interface DataBuffer {
/** /**
* Splits this data buffer into two at the given index. * Splits this data buffer into two at the given index.
*
* <p>Data that precedes the {@code index} will be returned in a new buffer, * <p>Data that precedes the {@code index} will be returned in a new buffer,
* while this buffer will contain data that follows after {@code index}. * while this buffer will contain data that follows after {@code index}.
* Memory between the two buffers is shared, but independent and cannot * Memory between the two buffers is shared, but independent and cannot
* overlap (unlike {@link #slice(int, int) slice}). * overlap (unlike {@link #slice(int, int) slice}).
*
* <p>The {@linkplain #readPosition() read} and * <p>The {@linkplain #readPosition() read} and
* {@linkplain #writePosition() write} position of the returned buffer are * {@linkplain #writePosition() write} position of the returned buffer are
* truncated to fit within the buffers {@linkplain #capacity() capacity} if * truncated to fit within the buffers {@linkplain #capacity() capacity} if
@ -384,22 +385,22 @@ public interface DataBuffer {
* will not be reflected in the reading nor writing position of this data buffer. * will not be reflected in the reading nor writing position of this data buffer.
* @return this data buffer as a byte buffer * @return this data buffer as a byte buffer
* @deprecated as of 6.0, in favor of {@link #toByteBuffer(ByteBuffer)}, * @deprecated as of 6.0, in favor of {@link #toByteBuffer(ByteBuffer)},
* {@link #readableByteBuffers()}, or {@link #writableByteBuffers()}. * {@link #readableByteBuffers()} or {@link #writableByteBuffers()}
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
ByteBuffer asByteBuffer(); ByteBuffer asByteBuffer();
/** /**
* Expose a subsequence of this buffer's bytes as a {@link ByteBuffer}. Data between * Expose a subsequence of this buffer's bytes as a {@link ByteBuffer}. Data
* this {@code DataBuffer} and the returned {@code ByteBuffer} is shared; though * between this {@code DataBuffer} and the returned {@code ByteBuffer} is shared;
* changes in the returned buffer's {@linkplain ByteBuffer#position() position} * though changes in the returned buffer's {@linkplain ByteBuffer#position() position}
* will not be reflected in the reading nor writing position of this data buffer. * will not be reflected in the reading nor writing position of this data buffer.
* @param index the index at which to start the byte buffer * @param index the index at which to start the byte buffer
* @param length the length of the returned byte buffer * @param length the length of the returned byte buffer
* @return this data buffer as a byte buffer * @return this data buffer as a byte buffer
* @since 5.0.1 * @since 5.0.1
* @deprecated as of 6.0, in favor of {@link #toByteBuffer(int, ByteBuffer, int, int)}, * @deprecated as of 6.0, in favor of {@link #toByteBuffer(int, ByteBuffer, int, int)},
* {@link #readableByteBuffers()}, or {@link #writableByteBuffers()}. * {@link #readableByteBuffers()} or {@link #writableByteBuffers()}
*/ */
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
ByteBuffer asByteBuffer(int index, int length); ByteBuffer asByteBuffer(int index, int length);
@ -553,6 +554,7 @@ public interface DataBuffer {
void close(); void close();
} }
/** /**
* Process a range of bytes one by one. * Process a range of bytes one by one.
* @since 6.2.12 * @since 6.2.12
@ -565,10 +567,9 @@ public interface DataBuffer {
* should continue further. * should continue further.
* @param b a byte from the {@link DataBuffer} * @param b a byte from the {@link DataBuffer}
* @return {@code true} if processing should continue, * @return {@code true} if processing should continue,
* or {@code false} if processing should stop at this element. * or {@code false} if processing should stop at this element
*/ */
boolean process(byte b); boolean process(byte b);
} }
} }

1
spring-web/src/main/java/org/springframework/web/bind/support/SpringWebConstraintValidatorFactory.java

@ -44,7 +44,6 @@ public class SpringWebConstraintValidatorFactory implements ConstraintValidatorF
return getWebApplicationContext().getAutowireCapableBeanFactory().createBean(key); return getWebApplicationContext().getAutowireCapableBeanFactory().createBean(key);
} }
// Bean Validation 1.1 releaseInstance method
@Override @Override
public void releaseInstance(ConstraintValidator<?, ?> instance) { public void releaseInstance(ConstraintValidator<?, ?> instance) {
getWebApplicationContext().getAutowireCapableBeanFactory().destroyBean(instance); getWebApplicationContext().getAutowireCapableBeanFactory().destroyBean(instance);

7
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xslt/XsltView.java

@ -431,11 +431,10 @@ public class XsltView extends AbstractUrlBasedView {
private Templates loadTemplates() throws ApplicationContextException { private Templates loadTemplates() throws ApplicationContextException {
Source stylesheetSource = getStylesheetSource(); Source stylesheetSource = getStylesheetSource();
try { try {
Templates templates = getTransformerFactory().newTemplates(stylesheetSource); return getTransformerFactory().newTemplates(stylesheetSource);
return templates;
} }
catch (TransformerConfigurationException ex) { catch (TransformerConfigurationException ex) {
throw new ApplicationContextException("Can't load stylesheet from '" + getUrl() + "'", ex); throw new ApplicationContextException("Cannot load stylesheet from '" + getUrl() + "'", ex);
} }
finally { finally {
closeSourceIfNecessary(stylesheetSource); closeSourceIfNecessary(stylesheetSource);
@ -474,7 +473,7 @@ public class XsltView extends AbstractUrlBasedView {
return new StreamSource(resource.getInputStream(), resource.getURI().toASCIIString()); return new StreamSource(resource.getInputStream(), resource.getURI().toASCIIString());
} }
catch (IOException ex) { catch (IOException ex) {
throw new ApplicationContextException("Can't load XSLT stylesheet from '" + url + "'", ex); throw new ApplicationContextException("Cannot load XSLT stylesheet from '" + url + "'", ex);
} }
} }

Loading…
Cancel
Save