JBossWeb SVN: r2305 - branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-11-08 14:12:17 -0500 (Fri, 08 Nov 2013)
New Revision: 2305
Modified:
branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime/PageContextImpl.java
Log:
[JBPAPP-10900] merge JBWEB-284
Modified: branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime/PageContextImpl.java
===================================================================
--- branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime/PageContextImpl.java 2013-11-08 18:03:49 UTC (rev 2304)
+++ branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime/PageContextImpl.java 2013-11-08 19:12:17 UTC (rev 2305)
@@ -421,8 +421,13 @@
return REQUEST_SCOPE;
if (session != null) {
- if (session.getAttribute(name) != null)
- return SESSION_SCOPE;
+ try {
+ if (session.getAttribute(name) != null)
+ return SESSION_SCOPE;
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
}
if (context.getAttribute(name) != null)
@@ -464,7 +469,12 @@
return o;
if (session != null) {
- o = session.getAttribute(name);
+ try {
+ o = session.getAttribute(name);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall through to application scope.
+ }
if (o != null)
return o;
}
@@ -528,17 +538,17 @@
}
private void doRemoveAttribute(String name) {
- try {
- removeAttribute(name, PAGE_SCOPE);
- removeAttribute(name, REQUEST_SCOPE);
- if (session != null) {
- removeAttribute(name, SESSION_SCOPE);
- }
- removeAttribute(name, APPLICATION_SCOPE);
- } catch (Exception ex) {
- // we remove as much as we can, and
- // simply ignore possible exceptions
- }
+ removeAttribute(name, PAGE_SCOPE);
+ removeAttribute(name, REQUEST_SCOPE);
+ if( session != null ) {
+ try {
+ removeAttribute(name, SESSION_SCOPE);
+ } catch(IllegalStateException ise) {
+ // Session has been invalidated.
+ // Ignore and fall throw to application scope.
+ }
+ }
+ removeAttribute(name, APPLICATION_SCOPE);
}
public JspWriter getOut() {
Property changes on: branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/java/org/apache/jasper/runtime/PageContextImpl.java
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/2.1.x/java/org/apache/jasper/runtime/PageContextImpl.java:2292
/trunk/java/org/apache/jasper/runtime/PageContextImpl.java:1009
11 years, 1 month
JBossWeb SVN: r2304 - branches.
by jbossweb-commits@lists.jboss.org
Author: aogburn
Date: 2013-11-08 13:03:49 -0500 (Fri, 08 Nov 2013)
New Revision: 2304
Added:
branches/JBOSSWEB_2_1_10_GA_JBPAPP-10900/
Log:
[JBPAPP-10900] create one-off branch
11 years, 1 month
JBossWeb SVN: r2303 - in branches/7.4.x: src/main/java/org/apache/jasper/compiler and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-11-06 12:07:31 -0500 (Wed, 06 Nov 2013)
New Revision: 2303
Modified:
branches/7.4.x/.classpath
branches/7.4.x/pom.xml
branches/7.4.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java
Log:
- POM cleanup.
- Support newer JDT.
Modified: branches/7.4.x/.classpath
===================================================================
--- branches/7.4.x/.classpath 2013-11-06 13:05:56 UTC (rev 2302)
+++ branches/7.4.x/.classpath 2013-11-06 17:07:31 UTC (rev 2303)
@@ -6,7 +6,7 @@
<classpathentry kind="lib" path="/home/remm/.m2/repository/org/jboss/spec/javax/servlet/jboss-servlet-api_3.0_spec/1.0.1.Final/jboss-servlet-api_3.0_spec-1.0.1.Final.jar"/>
<classpathentry kind="lib" path="/home/remm/.m2/repository/org/jboss/spec/javax/servlet/jsp/jboss-jsp-api_2.2_spec/1.0.1.Final/jboss-jsp-api_2.2_spec-1.0.1.Final.jar"/>
<classpathentry kind="lib" path="/home/remm/.m2/repository/org/jboss/spec/javax/el/jboss-el-api_2.2_spec/1.0.1.Final/jboss-el-api_2.2_spec-1.0.1.Final.jar"/>
- <classpathentry kind="lib" path="/home/remm/.m2/repository/org/jboss/web/jasper-jdt/7.0.3.Final/jasper-jdt-7.0.3.Final.jar"/>
<classpathentry kind="lib" path="/home/remm/.m2/repository/org/jboss/spec/javax/websocket/jboss-websocket-api_1.0_spec/1.0.0.Beta1/jboss-websocket-api_1.0_spec-1.0.0.Beta1.jar"/>
+ <classpathentry kind="lib" path="/home/remm/.m2/repository/org/eclipse/jdt/core/compiler/ecj/4.2.2/ecj-4.2.2.jar"/>
<classpathentry kind="output" path=".settings/output"/>
</classpath>
Modified: branches/7.4.x/pom.xml
===================================================================
--- branches/7.4.x/pom.xml 2013-11-06 13:05:56 UTC (rev 2302)
+++ branches/7.4.x/pom.xml 2013-11-06 17:07:31 UTC (rev 2303)
@@ -45,9 +45,7 @@
<version.org.jboss.spec.javax.el>1.0.1.Final</version.org.jboss.spec.javax.el>
<version.org.jboss.spec.javax.servlet>1.0.1.Final</version.org.jboss.spec.javax.servlet>
<version.org.jboss.spec.javax.servlet.jsp>1.0.1.Final</version.org.jboss.spec.javax.servlet.jsp>
- <version.org.jboss.spec.javax.websocket>1.0.0.Beta1</version.org.jboss.spec.javax.websocket>
- <version.org.eclipse.jdt.core.compiler.ecj>3.7.2</version.org.eclipse.jdt.core.compiler.ecj>
- <version.org.jboss.xnio>3.0.4.GA</version.org.jboss.xnio>
+ <version.org.eclipse.jdt.core.compiler.ecj>4.2.2</version.org.eclipse.jdt.core.compiler.ecj>
<!-- Build configuration -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
@@ -103,19 +101,6 @@
<dependencies>
<dependency>
- <groupId>org.jboss.xnio</groupId>
- <artifactId>xnio-api</artifactId>
- <version>${version.org.jboss.xnio}</version>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.xnio</groupId>
- <artifactId>xnio-nio</artifactId>
- <version>${version.org.jboss.xnio}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>${version.org.jboss.logging.jboss-logging}</version>
@@ -157,13 +142,6 @@
</dependency>
<dependency>
- <groupId>org.jboss.spec.javax.websocket</groupId>
- <artifactId>jboss-websocket-api_1.0_spec</artifactId>
- <version>${version.org.jboss.spec.javax.websocket}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
<groupId>org.eclipse.jdt.core.compiler</groupId>
<artifactId>ecj</artifactId>
<version>${version.org.eclipse.jdt.core.compiler.ecj}</version>
Modified: branches/7.4.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java 2013-11-06 13:05:56 UTC (rev 2302)
+++ branches/7.4.x/src/main/java/org/apache/jasper/compiler/JDTCompiler.java 2013-11-06 17:07:31 UTC (rev 2303)
@@ -155,6 +155,10 @@
}
return result;
}
+
+ public boolean ignoreOptionalProblems() {
+ return false;
+ }
}
final INameEnvironment env = new INameEnvironment() {
11 years, 1 month
JBossWeb SVN: r2302 - branches/7.4.x/src/main/java/org/apache/tomcat/util/net.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-11-06 08:05:56 -0500 (Wed, 06 Nov 2013)
New Revision: 2302
Modified:
branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
Log:
- Experiment with dropping recycling of the various runnables used for the processor, completion handlers, and other small utility structures (sendfile and channels in the "poller").
- Remove connection tracking (jio doesn't do it, so I don't understand why it is needed, closing the main channel is probably enough when stopping).
Modified: branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2013-11-06 09:38:04 UTC (rev 2301)
+++ branches/7.4.x/src/main/java/org/apache/tomcat/util/net/NioEndpoint.java 2013-11-06 13:05:56 UTC (rev 2302)
@@ -57,9 +57,6 @@
public class NioEndpoint extends AbstractEndpoint {
private AsynchronousServerSocketChannel listener;
- private ConcurrentHashMap<Long, NioChannel> connections;
- private ConcurrentLinkedQueue<ChannelProcessor> recycledChannelProcessors;
- private ConcurrentLinkedQueue<HandshakeHandler> recycledHandshakeProcessors;
/**
* Handling of accepted sockets.
@@ -182,18 +179,6 @@
this.threadFactory = new DefaultThreadFactory(getName() + "-", threadPriority);
}
- if (this.connections == null) {
- this.connections = new ConcurrentHashMap<Long, NioChannel>();
- }
-
- if (this.recycledChannelProcessors == null) {
- this.recycledChannelProcessors = new ConcurrentLinkedQueue<ChannelProcessor>();
- }
-
- if (this.recycledHandshakeProcessors == null) {
- this.recycledHandshakeProcessors = new ConcurrentLinkedQueue<HandshakeHandler>();
- }
-
// If the executor is not set, create it with a fixed thread pool
if (this.executor == null) {
this.executor = Executors.newFixedThreadPool(this.maxThreads, this.threadFactory);
@@ -307,25 +292,9 @@
this.eventPoller.destroy();
}
- // Closing all alive connections
- for (NioChannel ch : this.connections.values()) {
- try {
- ch.close();
- } catch (Throwable t) {
- // Nothing to do
- }
- }
- // Remove all connections
- this.connections.clear();
// Destroy the server socket channel factory
this.serverSocketChannelFactory.destroy();
this.serverSocketChannelFactory = null;
- // Destroy all recycled channel processors
- this.recycledChannelProcessors.clear();
- this.recycledChannelProcessors = null;
- // Destroy all recycled handshake processors
- this.recycledHandshakeProcessors.clear();
- this.recycledHandshakeProcessors = null;
// Shut down the executor
((ExecutorService) this.executor).shutdown();
@@ -481,8 +450,7 @@
return false;
}
try {
- ChannelProcessor processor = getChannelProcessor(channel, status);
- this.executor.execute(processor);
+ this.executor.execute(new ChannelProcessor(channel, status));
return true;
} catch (Throwable t) {
// This means we got an OOM or similar creating a thread, or that
@@ -498,8 +466,7 @@
*/
private boolean handshake(NioChannel channel) {
try {
- HandshakeHandler processor = getHandshakeProcessor(channel);
- this.executor.execute(processor);
+ this.executor.execute(new HandshakeHandler(channel));
return true;
} catch (Throwable t) {
// This means we got an OOM or similar creating a thread, or that
@@ -510,54 +477,6 @@
}
/**
- * @return peek a processor from the recycled processors list
- */
- private ChannelProcessor getChannelProcessor(NioChannel channel, SocketStatus status) {
- ChannelProcessor processor = this.recycledChannelProcessors.poll();
- if (processor == null) {
- processor = new ChannelProcessor(channel, status);
- } else {
- processor.setChannel(channel);
- processor.setStatus(status);
- }
- return processor;
- }
-
- /**
- * @return peek a handshake processor from the recycled processors list
- */
- private HandshakeHandler getHandshakeProcessor(NioChannel channel) {
- HandshakeHandler processor = this.recycledHandshakeProcessors.poll();
- if (processor == null) {
- processor = new HandshakeHandler(channel);
- } else {
- processor.setChannel(channel);
- }
- return processor;
- }
-
- /**
- * Try to add the specified channel to the list of connections.
- *
- * @param channel
- * the channel to be added
- * @return <tt>true</tt> if the channel is added successfully, else
- * <tt>false</tt>
- */
- private boolean addChannel(NioChannel channel) {
- if (this.counter.get() < this.maxConnections && channel.isOpen()) {
- if (this.connections.get(channel.getId()) == null
- || this.connections.get(channel.getId()).isClosed()) {
- this.connections.put(channel.getId(), channel);
- this.counter.incrementAndGet();
- return true;
- }
- }
-
- return false;
- }
-
- /**
* Getter for serverSocketChannelFactory
*
* @return the serverSocketChannelFactory
@@ -590,10 +509,6 @@
channel.close();
} catch (IOException e) {
CoyoteLogger.UTIL_LOGGER.errorClosingSocket(e);
- } finally {
- if (this.connections.remove(channel.getId()) != null) {
- this.counter.decrementAndGet();
- }
}
}
}
@@ -603,7 +518,7 @@
* from the pool, else <tt>null</tt>
*/
public SendfileData getSendfileData() {
- return this.sendfile != null ? this.sendfile.getSendfileData() : new SendfileData();
+ return new SendfileData();
}
/**
@@ -640,7 +555,7 @@
// channel
final NioChannel channel = serverSocketChannelFactory.acceptChannel(listener);
boolean ok = false;
- if (addChannel(channel) && setChannelOptions(channel) && channel.isOpen()) {
+ if (setChannelOptions(channel) && channel.isOpen()) {
if (channel.isSecure()) {
handshake(channel);
ok = true;
@@ -709,29 +624,9 @@
} catch (Exception exp) {
CoyoteLogger.UTIL_LOGGER.errorProcessingChannelDebug(exp);
closeChannel(channel);
- } finally {
- this.recycle();
}
}
- /**
- * Recycle the handshake processor
- */
- private void recycle() {
- this.channel = null;
- if (recycledHandshakeProcessors != null) {
- recycledHandshakeProcessors.offer(this);
- }
- }
-
- /**
- * Setter for the channel
- *
- * @param channel
- */
- public void setChannel(NioChannel channel) {
- this.channel = channel;
- }
}
/**
@@ -802,15 +697,6 @@
}
/**
- * Recycle this channel info for next use
- */
- public void recycle() {
- this.channel = null;
- this.timeout = 0;
- this.flags = 0;
- }
-
- /**
* @return the read flag
*/
public boolean read() {
@@ -1036,45 +922,9 @@
}
} catch (Throwable th) {
CoyoteLogger.UTIL_LOGGER.errorProcessingChannelWithException(th);
- } finally {
- this.recycle();
}
}
- /**
- * Reset this channel processor
- */
- protected void recycle() {
- this.channel = null;
- this.status = null;
- if (recycledChannelProcessors != null) {
- recycledChannelProcessors.offer(this);
- }
- }
-
- /**
- *
- * @param channel
- * @param status
- */
- protected void setup(NioChannel channel, SocketStatus status) {
- this.channel = channel;
- this.status = status;
- }
-
- /**
- * @param status
- */
- public void setStatus(SocketStatus status) {
- this.status = status;
- }
-
- /**
- * @param channel
- */
- public void setChannel(NioChannel channel) {
- this.channel = channel;
- }
}
/**
@@ -1092,8 +942,6 @@
protected long lastMaintain = System.currentTimeMillis();
protected ConcurrentHashMap<Long, ChannelInfo> channelList;
- protected ConcurrentLinkedQueue<ChannelInfo> recycledChannelList;
- private ConcurrentLinkedQueue<CompletionHandler<Integer, NioChannel>> recycledCompletionHandlers;
private Object mutex;
private int size;
@@ -1176,8 +1024,7 @@
* @param id
*/
protected boolean remove(long id) {
- ChannelInfo info = this.channelList.remove(id);
- return offer(info);
+ return this.channelList.remove(id) != null;
}
/**
@@ -1202,8 +1049,6 @@
public void init() {
this.mutex = new Object();
this.channelList = new ConcurrentHashMap<Long, ChannelInfo>(this.size);
- this.recycledChannelList = new ConcurrentLinkedQueue<ChannelInfo>();
- this.recycledCompletionHandlers = new ConcurrentLinkedQueue<CompletionHandler<Integer, NioChannel>>();
}
/**
@@ -1212,87 +1057,42 @@
public void destroy() {
synchronized (this.mutex) {
this.channelList.clear();
- this.recycledChannelList.clear();
- this.recycledCompletionHandlers.clear();
this.mutex.notifyAll();
}
}
/**
+ * Create a completion handler for read.
*
- * @return
- */
- protected ChannelInfo poll() {
- ChannelInfo info = this.recycledChannelList.poll();
- if (info == null) {
- info = new ChannelInfo();
- }
- return info;
- }
-
- /**
- * Recycle the the {@link ChannelInfo}
- *
- * @param info
- */
- protected boolean offer(ChannelInfo info) {
- if (info != null) {
- info.recycle();
- return this.recycledChannelList.offer(info);
- }
- return false;
- }
-
- /**
- * Peek a {@link java.nio.CompletionHandler} from the list of recycled
- * handlers. If the list is empty, create a new one and return it.
- *
* @return a reference of {@link java.nio.CompletionHandler}
*/
private CompletionHandler<Integer, NioChannel> getCompletionHandler() {
- CompletionHandler<Integer, NioChannel> handler = this.recycledCompletionHandlers.poll();
- if (handler == null) {
- handler = new CompletionHandler<Integer, NioChannel>() {
+ CompletionHandler<Integer, NioChannel> handler = new CompletionHandler<Integer, NioChannel>() {
+ @Override
+ public void completed(Integer nBytes, NioChannel attach) {
+ if (nBytes < 0) {
+ failed(new ClosedChannelException(), attach);
+ } else {
+ remove(attach);
+ if (!processChannel(attach, SocketStatus.OPEN_READ)) {
+ closeChannel(attach);
+ }
+ }
+ }
- @Override
- public void completed(Integer nBytes, NioChannel attach) {
- if (nBytes < 0) {
- failed(new ClosedChannelException(), attach);
- } else {
- remove(attach);
- if (!processChannel(attach, SocketStatus.OPEN_READ)) {
- closeChannel(attach);
- }
- // Recycle the completion handler
- recycleHanlder(this);
- }
- }
+ @Override
+ public void failed(Throwable exc, NioChannel attach) {
+ remove(attach);
+ if (!processChannel(attach, SocketStatus.ERROR)) {
+ closeChannel(attach);
+ }
+ }
+ };
- @Override
- public void failed(Throwable exc, NioChannel attach) {
- remove(attach);
- if (!processChannel(attach, SocketStatus.ERROR)) {
- closeChannel(attach);
- }
- // Recycle the completion handler
- recycleHanlder(this);
- }
- };
- }
-
return handler;
}
/**
- * Recycle the {@link java.nio.CompletionHandler}
- *
- * @param handler
- */
- private void recycleHanlder(CompletionHandler<Integer, NioChannel> handler) {
- this.recycledCompletionHandlers.offer(handler);
- }
-
- /**
* Add the channel to the list of channels
*
* @param channel
@@ -1310,7 +1110,7 @@
ChannelInfo info = this.channelList.get(channel.getId());
if (info == null) {
- info = poll();
+ info = new ChannelInfo();
info.channel = channel;
info.flags = flag;
this.channelList.put(channel.getId(), info);
@@ -1440,25 +1240,6 @@
}
/**
- * Recycle this {@code SendfileData}
- */
- protected void recycle() {
- this.start = 0;
- this.end = 0;
- this.pos = 0;
- this.channel = null;
- this.keepAlive = false;
- if (this.fileChannel != null && this.fileChannel.isOpen()) {
- try {
- this.fileChannel.close();
- } catch (IOException e) {
- // Ignore
- }
- }
- this.fileChannel = null;
- }
-
- /**
* Getter for fileName
*
* @return the fileName
@@ -1584,7 +1365,6 @@
protected int size;
protected ConcurrentLinkedQueue<SendfileData> fileDatas;
- protected ConcurrentLinkedQueue<SendfileData> recycledFileDatas;
protected AtomicInteger counter;
private Object mutex;
@@ -1644,7 +1424,6 @@
this.mutex = new Object();
this.counter = new AtomicInteger(0);
this.fileDatas = new ConcurrentLinkedQueue<SendfileData>();
- this.recycledFileDatas = new ConcurrentLinkedQueue<SendfileData>();
}
/**
@@ -1655,33 +1434,13 @@
// To unlock the
this.counter.incrementAndGet();
this.fileDatas.clear();
- this.recycledFileDatas.clear();
// Unlock threads waiting for this monitor
this.mutex.notifyAll();
}
}
/**
- * @param data
- */
- public void recycleSendfileData(SendfileData data) {
- data.recycle();
- this.recycledFileDatas.offer(data);
- }
-
- /**
- * Poll the head of the recycled object list if it is not empty, else
- * create a new one.
*
- * @return a {@code SendfileData}
- */
- public SendfileData getSendfileData() {
- SendfileData data = this.recycledFileDatas.poll();
- return data == null ? new SendfileData() : data;
- }
-
- /**
- *
* @param data
* @throws Exception
*/
@@ -1711,8 +1470,6 @@
attachment.pos += nw;
if (attachment.pos >= attachment.end) {
- // All requested bytes were sent, recycle it
- recycleSendfileData(attachment);
return;
}
@@ -1765,8 +1522,6 @@
data.fileChannel.close();
add(data);
}
- } else {
- recycleSendfileData(data);
}
}
11 years, 1 month
JBossWeb SVN: r2301 - in branches/7.4.x/src/main/java/org/apache/jasper: runtime and 1 other directory.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-11-06 04:38:04 -0500 (Wed, 06 Nov 2013)
New Revision: 2301
Modified:
branches/7.4.x/src/main/java/org/apache/jasper/compiler/ELParser.java
branches/7.4.x/src/main/java/org/apache/jasper/compiler/Validator.java
branches/7.4.x/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
Log:
Port fix for some EL processing
https://issues.apache.org/bugzilla/show_bug.cgi?id=55735
Modified: branches/7.4.x/src/main/java/org/apache/jasper/compiler/ELParser.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/jasper/compiler/ELParser.java 2013-11-05 16:23:32 UTC (rev 2300)
+++ branches/7.4.x/src/main/java/org/apache/jasper/compiler/ELParser.java 2013-11-06 09:38:04 UTC (rev 2301)
@@ -17,6 +17,12 @@
package org.apache.jasper.compiler;
+import org.apache.jasper.JasperException;
+import org.apache.jasper.compiler.ELNode.ELText;
+import org.apache.jasper.compiler.ELNode.Function;
+import org.apache.jasper.compiler.ELNode.Root;
+import org.apache.jasper.compiler.ELNode.Text;
+
/**
* This class implements a parser for EL expressions.
*
@@ -106,6 +112,7 @@
// Output whatever is in buffer
if (buf.length() > 0) {
ELexpr.add(new ELNode.ELText(buf.toString()));
+ buf = new StringBuilder();
}
if (!parseFunction()) {
ELexpr.add(new ELNode.ELText(curToken.toString()));
@@ -131,8 +138,8 @@
}
String s1 = null; // Function prefix
String s2 = curToken.toString(); // Function name
- int mark = getIndex();
if (hasNext()) {
+ int mark = getIndex();
curToken = nextToken();
if (curToken.toChar() == ':') {
if (hasNext()) {
@@ -150,8 +157,9 @@
ELexpr.add(new ELNode.Function(s1, s2));
return true;
}
+ curToken = prevToken;
+ setIndex(mark);
}
- setIndex(mark);
return false;
}
@@ -389,4 +397,41 @@
public char getType() {
return type;
}
+
+ protected static class TextBuilder extends ELNode.Visitor {
+
+ protected StringBuilder output = new StringBuilder();
+
+ public String getText() {
+ return output.toString();
+ }
+
+ @Override
+ public void visit(Root n) throws JasperException {
+ output.append(n.getType());
+ output.append('{');
+ n.getExpression().visit(this);
+ output.append('}');
+ }
+
+ @Override
+ public void visit(Function n) throws JasperException {
+ if (n.getPrefix() != null) {
+ output.append(n.getPrefix());
+ output.append(':');
+ }
+ output.append(n.getName());
+ output.append('(');
+ }
+
+ @Override
+ public void visit(Text n) throws JasperException {
+ output.append(n.getText());
+ }
+
+ @Override
+ public void visit(ELText n) throws JasperException {
+ output.append(n.getText());
+ }
+ }
}
Modified: branches/7.4.x/src/main/java/org/apache/jasper/compiler/Validator.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/jasper/compiler/Validator.java 2013-11-05 16:23:32 UTC (rev 2300)
+++ branches/7.4.x/src/main/java/org/apache/jasper/compiler/Validator.java 2013-11-06 09:38:04 UTC (rev 2301)
@@ -41,6 +41,7 @@
import javax.servlet.jsp.tagext.ValidationMessage;
import org.apache.jasper.JasperException;
+import org.apache.jasper.compiler.ELNode.Text;
import org.apache.jasper.el.ELContextImpl;
import org.xml.sax.Attributes;
@@ -1352,8 +1353,16 @@
validateFunctions(el, n);
- result = new Node.JspAttribute(tai, qName, uri,
- localName, value, false, el, dynamic);
+ if (n.getRoot().isXmlSyntax()) {
+ // The non-EL elements need to be XML escaped
+ XmlEscapeNonELVisitor v = new XmlEscapeNonELVisitor();
+ el.visit(v);
+ result = new Node.JspAttribute(tai, qName, uri,
+ localName, v.getText(), false, el, dynamic);
+ } else {
+ result = new Node.JspAttribute(tai, qName, uri,
+ localName, value, false, el, dynamic);
+ }
ELContextImpl ctx = new ELContextImpl();
ctx.setFunctionMapper(getFunctionMapper(el));
@@ -1387,6 +1396,14 @@
return result;
}
+ private static class XmlEscapeNonELVisitor extends ELParser.TextBuilder {
+
+ @Override
+ public void visit(Text n) throws JasperException {
+ output.append(xmlEscape(n.getText()));
+ }
+ }
+
/*
* Return an empty StringBuilder [not thread-safe]
*/
@@ -1810,4 +1827,67 @@
errDisp.jspError(errMsg.toString());
}
}
+
+ protected static String xmlEscape(String s) {
+ if (s == null) {
+ return null;
+ }
+ int len = s.length();
+
+ /*
+ * Look for any "bad" characters, Escape "bad" character was found
+ */
+ // ASCII " 34 & 38 ' 39 < 60 > 62
+ for (int i = 0; i < len; i++) {
+ char c = s.charAt(i);
+ if (c >= '\"' && c <= '>' &&
+ (c == '<' || c == '>' || c == '\'' || c == '&' || c == '"')) {
+ // need to escape them and then quote the whole string
+ StringBuilder sb = new StringBuilder((int) (len * 1.2));
+ sb.append(s, 0, i);
+ int pos = i + 1;
+ for (int j = i; j < len; j++) {
+ c = s.charAt(j);
+ if (c >= '\"' && c <= '>') {
+ if (c == '<') {
+ if (j > pos) {
+ sb.append(s, pos, j);
+ }
+ sb.append("<");
+ pos = j + 1;
+ } else if (c == '>') {
+ if (j > pos) {
+ sb.append(s, pos, j);
+ }
+ sb.append(">");
+ pos = j + 1;
+ } else if (c == '\'') {
+ if (j > pos) {
+ sb.append(s, pos, j);
+ }
+ sb.append("'"); // '
+ pos = j + 1;
+ } else if (c == '&') {
+ if (j > pos) {
+ sb.append(s, pos, j);
+ }
+ sb.append("&");
+ pos = j + 1;
+ } else if (c == '"') {
+ if (j > pos) {
+ sb.append(s, pos, j);
+ }
+ sb.append("""); // "
+ pos = j + 1;
+ }
+ }
+ }
+ if (pos < len) {
+ sb.append(s, pos, len);
+ }
+ return sb.toString();
+ }
+ }
+ return s;
+ }
}
Modified: branches/7.4.x/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
===================================================================
--- branches/7.4.x/src/main/java/org/apache/jasper/runtime/PageContextImpl.java 2013-11-05 16:23:32 UTC (rev 2300)
+++ branches/7.4.x/src/main/java/org/apache/jasper/runtime/PageContextImpl.java 2013-11-06 09:38:04 UTC (rev 2301)
@@ -846,69 +846,6 @@
}
}
- protected static String XmlEscape(String s) {
- if (s == null) {
- return null;
- }
- int len = s.length();
-
- /*
- * Look for any "bad" characters, Escape "bad" character was found
- */
- // ASCII " 34 & 38 ' 39 < 60 > 62
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c >= '\"' && c <= '>' &&
- (c == '<' || c == '>' || c == '\'' || c == '&' || c == '"')) {
- // need to escape them and then quote the whole string
- StringBuilder sb = new StringBuilder((int) (len * 1.2));
- sb.append(s, 0, i);
- int pos = i + 1;
- for (int j = i; j < len; j++) {
- c = s.charAt(j);
- if (c >= '\"' && c <= '>') {
- if (c == '<') {
- if (j > pos) {
- sb.append(s, pos, j);
- }
- sb.append("<");
- pos = j + 1;
- } else if (c == '>') {
- if (j > pos) {
- sb.append(s, pos, j);
- }
- sb.append(">");
- pos = j + 1;
- } else if (c == '\'') {
- if (j > pos) {
- sb.append(s, pos, j);
- }
- sb.append("'"); // '
- pos = j + 1;
- } else if (c == '&') {
- if (j > pos) {
- sb.append(s, pos, j);
- }
- sb.append("&");
- pos = j + 1;
- } else if (c == '"') {
- if (j > pos) {
- sb.append(s, pos, j);
- }
- sb.append("""); // "
- pos = j + 1;
- }
- }
- }
- if (pos < len) {
- sb.append(s, pos, len);
- }
- return sb.toString();
- }
- }
- return s;
- }
-
/**
* Proprietary method to evaluate EL expressions. XXX - This method should
* go away once the EL interpreter moves out of JSTL and into its own
@@ -957,10 +894,6 @@
ValueExpression ve = exprFactory.createValueExpression(ctx, expression, expectedType);
retValue = ve.getValue(ctx);
}
- if (escape && retValue != null) {
- retValue = XmlEscape(retValue.toString());
- }
-
return retValue;
}
11 years, 1 month
JBossWeb SVN: r2300 - in branches/7.4.x: res and 3 other directories.
by jbossweb-commits@lists.jboss.org
Author: remy.maucherat(a)jboss.com
Date: 2013-11-05 11:23:32 -0500 (Tue, 05 Nov 2013)
New Revision: 2300
Added:
branches/7.4.x/res/
branches/7.4.x/res/enable-websockets.jar
branches/7.4.x/res/enable-websockets/
branches/7.4.x/res/enable-websockets/META-INF/
branches/7.4.x/res/enable-websockets/META-INF/services/
branches/7.4.x/res/enable-websockets/META-INF/services/javax.servlet.ServletContainerInitializer
branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.ContainerProvider
branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator
branches/7.4.x/res/enable-websockets/META-INF/web-fragment.xml
Log:
Add the marker JAR that allows enabling websockets in a webapp.
Added: branches/7.4.x/res/enable-websockets/META-INF/services/javax.servlet.ServletContainerInitializer
===================================================================
--- branches/7.4.x/res/enable-websockets/META-INF/services/javax.servlet.ServletContainerInitializer (rev 0)
+++ branches/7.4.x/res/enable-websockets/META-INF/services/javax.servlet.ServletContainerInitializer 2013-11-05 16:23:32 UTC (rev 2300)
@@ -0,0 +1 @@
+org.apache.tomcat.websocket.server.WsSci
\ No newline at end of file
Added: branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.ContainerProvider
===================================================================
--- branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.ContainerProvider (rev 0)
+++ branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.ContainerProvider 2013-11-05 16:23:32 UTC (rev 2300)
@@ -0,0 +1 @@
+org.apache.tomcat.websocket.WsContainerProvider
\ No newline at end of file
Added: branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator
===================================================================
--- branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator (rev 0)
+++ branches/7.4.x/res/enable-websockets/META-INF/services/javax.websocket.server.ServerEndpointConfig$Configurator 2013-11-05 16:23:32 UTC (rev 2300)
@@ -0,0 +1 @@
+org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator
\ No newline at end of file
Added: branches/7.4.x/res/enable-websockets/META-INF/web-fragment.xml
===================================================================
(Binary files differ)
Property changes on: branches/7.4.x/res/enable-websockets/META-INF/web-fragment.xml
___________________________________________________________________
Added: svn:mime-type
+ application/xml
Added: branches/7.4.x/res/enable-websockets.jar
===================================================================
(Binary files differ)
Property changes on: branches/7.4.x/res/enable-websockets.jar
___________________________________________________________________
Added: svn:mime-type
+ application/zip
11 years, 1 month