You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2012/09/03 22:14:30 UTC
svn commit: r1380342 -
/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
Author: pmouawad
Date: Mon Sep 3 20:14:30 2012
New Revision: 1380342
URL: http://svn.apache.org/viewvc?rev=1380342&view=rev
Log:
Remove caching as it is subject to thread corruption
Modified:
jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=1380342&r1=1380341&r2=1380342&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java Mon Sep 3 20:14:30 2012
@@ -42,9 +42,6 @@ public class XPathPanel extends JPanel {
private static final Logger log = LoggingManager.getLoggerForClass();
- // Lazily constructed. Does not matter if it is constructed more than once.
- private static Document testDoc;
-
private JCheckBox negated;
private JTextField xpath;
@@ -182,14 +179,11 @@ public class XPathPanel extends JPanel {
public static boolean validXPath(String xpathString, boolean showDialog) {
String ret = null;
boolean success = true;
+ Document testDoc = null;
try {
- if (testDoc == null) {
- Document doc = XPathUtil.makeDocumentBuilder(false, false, false, false).newDocument();
- testDoc = doc;
- Element el = testDoc.createElement("root"); //$NON-NLS-1$
- doc.appendChild(el);
-
- }
+ testDoc = XPathUtil.makeDocumentBuilder(false, false, false, false).newDocument();
+ Element el = testDoc.createElement("root"); //$NON-NLS-1$
+ testDoc.appendChild(el);
XPathUtil.validateXPath(testDoc, xpathString);
} catch (IllegalArgumentException e) {
log.warn(e.getLocalizedMessage());
Re: svn commit: r1380342 - /jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
Posted by Philippe Mouawad <ph...@gmail.com>.
I think you are right, only awt thread accesses it so it should be ok on
this side
In my understanding it caches in a static var the document used for testIng
xpath.
I am not sure it's worth it and code seems to me not very clear.
You can rollback id you disagree
On Monday, September 3, 2012, sebb wrote:
> On 3 September 2012 21:14, <pmouawad@apache.org <javascript:;>> wrote:
> > Author: pmouawad
> > Date: Mon Sep 3 20:14:30 2012
> > New Revision: 1380342
> >
> > URL: http://svn.apache.org/viewvc?rev=1380342&view=rev
> > Log:
> > Remove caching as it is subject to thread corruption
>
> Are you sure?
>
> > Modified:
> >
> jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
> >
> > Modified:
> jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
> > URL:
> http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=1380342&r1=1380341&r2=1380342&view=diff
> >
> ==============================================================================
> > ---
> jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
> (original)
> > +++
> jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
> Mon Sep 3 20:14:30 2012
> > @@ -42,9 +42,6 @@ public class XPathPanel extends JPanel {
> >
> > private static final Logger log =
> LoggingManager.getLoggerForClass();
> >
> > - // Lazily constructed. Does not matter if it is constructed more
> than once.
> > - private static Document testDoc;
> > -
> > private JCheckBox negated;
> >
> > private JTextField xpath;
> > @@ -182,14 +179,11 @@ public class XPathPanel extends JPanel {
> > public static boolean validXPath(String xpathString, boolean
> showDialog) {
> > String ret = null;
> > boolean success = true;
> > + Document testDoc = null;
> > try {
> > - if (testDoc == null) {
> > - Document doc = XPathUtil.makeDocumentBuilder(false,
> false, false, false).newDocument();
> > - testDoc = doc;
> > - Element el = testDoc.createElement("root");
> //$NON-NLS-1$
> > - doc.appendChild(el);
> > -
> > - }
> > + testDoc = XPathUtil.makeDocumentBuilder(false, false,
> false, false).newDocument();
> > + Element el = testDoc.createElement("root"); //$NON-NLS-1$
> > + testDoc.appendChild(el);
> > XPathUtil.validateXPath(testDoc, xpathString);
> > } catch (IllegalArgumentException e) {
> > log.warn(e.getLocalizedMessage());
> >
> >
>
--
Cordialement.
Philippe Mouawad.
Re: svn commit: r1380342 - /jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
Posted by sebb <se...@gmail.com>.
On 3 September 2012 21:14, <pm...@apache.org> wrote:
> Author: pmouawad
> Date: Mon Sep 3 20:14:30 2012
> New Revision: 1380342
>
> URL: http://svn.apache.org/viewvc?rev=1380342&view=rev
> Log:
> Remove caching as it is subject to thread corruption
Are you sure?
> Modified:
> jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
>
> Modified: jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java
> URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java?rev=1380342&r1=1380341&r2=1380342&view=diff
> ==============================================================================
> --- jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java (original)
> +++ jmeter/trunk/src/components/org/apache/jmeter/assertions/gui/XPathPanel.java Mon Sep 3 20:14:30 2012
> @@ -42,9 +42,6 @@ public class XPathPanel extends JPanel {
>
> private static final Logger log = LoggingManager.getLoggerForClass();
>
> - // Lazily constructed. Does not matter if it is constructed more than once.
> - private static Document testDoc;
> -
> private JCheckBox negated;
>
> private JTextField xpath;
> @@ -182,14 +179,11 @@ public class XPathPanel extends JPanel {
> public static boolean validXPath(String xpathString, boolean showDialog) {
> String ret = null;
> boolean success = true;
> + Document testDoc = null;
> try {
> - if (testDoc == null) {
> - Document doc = XPathUtil.makeDocumentBuilder(false, false, false, false).newDocument();
> - testDoc = doc;
> - Element el = testDoc.createElement("root"); //$NON-NLS-1$
> - doc.appendChild(el);
> -
> - }
> + testDoc = XPathUtil.makeDocumentBuilder(false, false, false, false).newDocument();
> + Element el = testDoc.createElement("root"); //$NON-NLS-1$
> + testDoc.appendChild(el);
> XPathUtil.validateXPath(testDoc, xpathString);
> } catch (IllegalArgumentException e) {
> log.warn(e.getLocalizedMessage());
>
>