Polishing

This commit is contained in:
Juergen Hoeller 2017-06-26 18:59:17 +02:00
parent 098ff6f0f8
commit 140542e8b1
3 changed files with 17 additions and 22 deletions

View File

@ -90,14 +90,13 @@ public class SpelCompiler implements Opcodes {
/** /**
* Attempt compilation of the supplied expression. A check is * Attempt compilation of the supplied expression. A check is made to see
* made to see if it is compilable before compilation proceeds. The * if it is compilable before compilation proceeds. The check involves
* check involves visiting all the nodes in the expression Ast and * visiting all the nodes in the expression Ast and ensuring enough state
* ensuring enough state is known about them that bytecode can * is known about them that bytecode can be generated for them.
* be generated for them.
* @param expression the expression to compile * @param expression the expression to compile
* @return an instance of the class implementing the compiled expression, or null * @return an instance of the class implementing the compiled expression,
* if compilation is not possible * or {@code null} if compilation is not possible
*/ */
@Nullable @Nullable
public CompiledExpression compile(SpelNodeImpl expression) { public CompiledExpression compile(SpelNodeImpl expression) {
@ -193,7 +192,6 @@ public class SpelCompiler implements Opcodes {
* because they anchor compiled classes in memory and prevent GC. If you have expressions * because they anchor compiled classes in memory and prevent GC. If you have expressions
* continually recompiling over time then by replacing the classloader periodically * continually recompiling over time then by replacing the classloader periodically
* at least some of the older variants can be garbage collected. * at least some of the older variants can be garbage collected.
*
* @param name name of the class * @param name name of the class
* @param bytes bytecode for the class * @param bytes bytecode for the class
* @return the Class object for the compiled expression * @return the Class object for the compiled expression

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -44,14 +44,16 @@ public class MarshallingMessageConverterTests {
private Session sessionMock; private Session sessionMock;
@Before @Before
public void setUp() throws Exception { public void setup() throws Exception {
marshallerMock = mock(Marshaller.class); marshallerMock = mock(Marshaller.class);
unmarshallerMock = mock(Unmarshaller.class); unmarshallerMock = mock(Unmarshaller.class);
sessionMock = mock(Session.class); sessionMock = mock(Session.class);
converter = new MarshallingMessageConverter(marshallerMock, unmarshallerMock); converter = new MarshallingMessageConverter(marshallerMock, unmarshallerMock);
} }
@Test @Test
public void toBytesMessage() throws Exception { public void toBytesMessage() throws Exception {
BytesMessage bytesMessageMock = mock(BytesMessage.class); BytesMessage bytesMessageMock = mock(BytesMessage.class);
@ -102,4 +104,5 @@ public class MarshallingMessageConverterTests {
Object result = converter.fromMessage(textMessageMock); Object result = converter.fromMessage(textMessageMock);
assertEquals("Invalid result", result, unmarshalled); assertEquals("Invalid result", result, unmarshalled);
} }
} }

View File

@ -186,7 +186,7 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
@Test @Test
public void supportsPackagesToScan() throws Exception { public void supportsPackagesToScan() throws Exception {
marshaller = new Jaxb2Marshaller(); marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[] {CONTEXT_PATH}); marshaller.setPackagesToScan(CONTEXT_PATH);
marshaller.afterPropertiesSet(); marshaller.afterPropertiesSet();
testSupports(); testSupports();
} }
@ -306,11 +306,10 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
verify(mimeContainer, times(3)).addAttachment(isA(String.class), isA(DataHandler.class)); verify(mimeContainer, times(3)).addAttachment(isA(String.class), isA(DataHandler.class));
} }
@Test @Test // SPR-10714
public void marshalAWrappedObjectHoldingAnXmlElementDeclElement() throws Exception { public void marshalAWrappedObjectHoldingAnXmlElementDeclElement() throws Exception {
// SPR-10714
marshaller = new Jaxb2Marshaller(); marshaller = new Jaxb2Marshaller();
marshaller.setPackagesToScan(new String[]{"org.springframework.oxm.jaxb"}); marshaller.setPackagesToScan("org.springframework.oxm.jaxb");
marshaller.afterPropertiesSet(); marshaller.afterPropertiesSet();
Airplane airplane = new Airplane(); Airplane airplane = new Airplane();
airplane.setName("test"); airplane.setName("test");
@ -323,11 +322,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
isSimilarTo("<airplane><name>test</name></airplane>").withDifferenceEvaluator(ev)); isSimilarTo("<airplane><name>test</name></airplane>").withDifferenceEvaluator(ev));
} }
// SPR-10806 @Test // SPR-10806
@Test
public void unmarshalStreamSourceWithXmlOptions() throws Exception { public void unmarshalStreamSourceWithXmlOptions() throws Exception {
final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class); final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller() {
@Override @Override
@ -360,11 +356,8 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
assertEquals(true, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities")); assertEquals(true, result.getXMLReader().getFeature("http://xml.org/sax/features/external-general-entities"));
} }
// SPR-10806 @Test // SPR-10806
@Test
public void unmarshalSaxSourceWithXmlOptions() throws Exception { public void unmarshalSaxSourceWithXmlOptions() throws Exception {
final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class); final javax.xml.bind.Unmarshaller unmarshaller = mock(javax.xml.bind.Unmarshaller.class);
Jaxb2Marshaller marshaller = new Jaxb2Marshaller() { Jaxb2Marshaller marshaller = new Jaxb2Marshaller() {
@Override @Override
@ -421,4 +414,5 @@ public class Jaxb2MarshallerTests extends AbstractMarshallerTests<Jaxb2Marshalle
private JAXBElement<DummyType> createDummyType() { private JAXBElement<DummyType> createDummyType() {
return null; return null;
} }
} }