jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antonio Gomes Rodrigues <ra0...@gmail.com>
Subject Re: [GitHub] jmeter pull request: bug59153_ExceptionInCSVDataSetWithEmptyFilena...
Date Sun, 13 Mar 2016 20:40:56 GMT
Hi Sebb,

I have made a git diff

diff --git a/src/components/org/apache/jmeter/config/CSVDataSet.java
b/src/components/org/apache/jmeter/config/CSVDataSet.java
index 65c20b6..a702868 100644
--- a/src/components/org/apache/jmeter/config/CSVDataSet.java
+++ b/src/components/org/apache/jmeter/config/CSVDataSet.java
@@ -146,71 +146,76 @@ public class CSVDataSet extends ConfigTestElement

     @Override
     public void iterationStart(LoopIterationEvent iterEvent) {
-        FileServer server = FileServer.getFileServer();
-        final JMeterContext context = getThreadContext();
-        String delim = getDelimiter();
-        if (delim.equals("\\t")) { // $NON-NLS-1$
-            delim = "\t";// Make it easier to enter a Tab // $NON-NLS-1$
-        } else if (delim.length()==0){
-            log.warn("Empty delimiter converted to ','");
-            delim=",";
-        }
-        if (vars == null) {
-            String _fileName = getFilename();
-            String mode = getShareMode();
-            int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
-            switch(modeInt){
-                case CSVDataSetBeanInfo.SHARE_ALL:
-                    alias = _fileName;
-                    break;
-                case CSVDataSetBeanInfo.SHARE_GROUP:
-                    alias =
_fileName+"@"+System.identityHashCode(context.getThreadGroup());
-                    break;
-                case CSVDataSetBeanInfo.SHARE_THREAD:
-                    alias =
_fileName+"@"+System.identityHashCode(context.getThread());
-                    break;
-                default:
-                    alias = _fileName+"@"+mode; // user-specified key
-                    break;
+        String _fileName = getFilename();
+        if (!_fileName.isEmpty()) {
+            FileServer server = FileServer.getFileServer();
+            final JMeterContext context = getThreadContext();
+            String delim = getDelimiter();
+            if (delim.equals("\\t")) { // $NON-NLS-1$
+                delim = "\t";// Make it easier to enter a Tab //
$NON-NLS-1$
+            } else if (delim.length()==0){
+                log.warn("Empty delimiter converted to ','");
+                delim=",";
             }
-            final String names = getVariableNames();
-            if (names == null || names.length()==0) {
-                String header = server.reserveFile(_fileName,
getFileEncoding(), alias, true);
-                try {
-                    vars = CSVSaveService.csvSplitString(header,
delim.charAt(0));
-                    firstLineIsNames = true;
-                } catch (IOException e) {
-                    log.warn("Could not split CSV header line",e);
+            if (vars == null) {
+                String mode = getShareMode();
+                int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
+                switch(modeInt){
+                    case CSVDataSetBeanInfo.SHARE_ALL:
+                        alias = _fileName;
+                        break;
+                    case CSVDataSetBeanInfo.SHARE_GROUP:
+                        alias =
_fileName+"@"+System.identityHashCode(context.getThreadGroup());
+                        break;
+                    case CSVDataSetBeanInfo.SHARE_THREAD:
+                        alias =
_fileName+"@"+System.identityHashCode(context.getThread());
+                        break;
+                    default:
+                        alias = _fileName+"@"+mode; // user-specified key
+                        break;
+                }
+                final String names = getVariableNames();
+                if (names == null || names.length()==0) {
+                    String header = server.reserveFile(_fileName,
getFileEncoding(), alias, true);
+                    try {
+                        vars = CSVSaveService.csvSplitString(header,
delim.charAt(0));
+                        firstLineIsNames = true;
+                    } catch (IOException e) {
+                        log.warn("Could not split CSV header line",e);
+                    }
+                } else {
+                    server.reserveFile(_fileName, getFileEncoding(),
alias);
+                    vars = JOrphanUtils.split(names, ","); // $NON-NLS-1$
                 }
-            } else {
-                server.reserveFile(_fileName, getFileEncoding(), alias);
-                vars = JOrphanUtils.split(names, ","); // $NON-NLS-1$
-            }
-        }
-
-        // TODO: fetch this once as per vars above?
-        JMeterVariables threadVars = context.getVariables();
-        String[] lineValues = {};
-        try {
-            if (getQuotedData()) {
-                lineValues = server.getParsedLine(alias, recycle,
firstLineIsNames, delim.charAt(0));
-            } else {
-                String line = server.readLine(alias, recycle,
firstLineIsNames);
-                lineValues = JOrphanUtils.split(line, delim, false);
-            }
-            for (int a = 0; a < vars.length && a < lineValues.length; a++)
{
-                threadVars.put(vars[a], lineValues[a]);
             }
-        } catch (IOException e) { // treat the same as EOF
-            log.error(e.toString());
-        }
-        if (lineValues.length == 0) {// i.e. EOF
-            if (getStopThread()) {
-                throw new JMeterStopThreadException("End of file
detected");
+
+            // TODO: fetch this once as per vars above?
+            JMeterVariables threadVars = context.getVariables();
+            String[] lineValues = {};
+            try {
+                if (getQuotedData()) {
+                    lineValues = server.getParsedLine(alias, recycle,
firstLineIsNames, delim.charAt(0));
+                } else {
+                    String line = server.readLine(alias, recycle,
firstLineIsNames);
+                    lineValues = JOrphanUtils.split(line, delim, false);
+                }
+                for (int a = 0; a < vars.length && a < lineValues.length;
a++) {
+                    threadVars.put(vars[a], lineValues[a]);
+                }
+            } catch (IOException e) { // treat the same as EOF
+                log.error(e.toString());
             }
-            for (String var :vars) {
-                threadVars.put(var, EOFVALUE);
+            if (lineValues.length == 0) {// i.e. EOF
+                if (getStopThread()) {
+                    throw new JMeterStopThreadException("End of file
detected");
+                }
+                for (String var :vars) {
+                    threadVars.put(var, EOFVALUE);
+                }
             }
+        } else {
+            log.error("No filename setup in CSV Data Set Config:
"+this.getName());
+            throw new JMeterStopThreadException("No filename setup in CSV
Data Set Config: "+this.getName());
         }
     }



Antonio

2016-03-11 16:38 GMT+01:00 sebb <sebbaz@gmail.com>:

> Sorry, but that is even harder to understand.
>
> Please provide a proper unified diff or equivalent.
>
> On 11 March 2016 at 15:24, Antonio Gomes Rodrigues <ra0077@gmail.com>
> wrote:
> > Hi Sebb,
> >
> > In org.apache.jmeter.config.CSVDataSet class I have add in iterationStart
> > method
> >
> >     public void iterationStart(LoopIterationEvent iterEvent) {
> > (Move)        String _fileName = getFilename();
> > (Add)        if (!_fileName.isEmpty()) {
> >             FileServer server = FileServer.getFileServer();
> >
> > .....
> >
> >
> > (Add)        } else {
> > (Add)            log.error("No filename setup in CSV Data Set Config:
> > "+this.getName());
> > (Add)            throw new JMeterStopThreadException("No filename setup
> in
> > CSV Data Set Config: "+this.getName());
> >  (Add)       }
> >
> > Have I use the right exception (JMeterStopThreadException) to stop the
> test
> > plan execution?
> >
> > Antonio
> >
> >
> > Cet e-mail a été envoyé depuis un ordinateur protégé par Avast.
> > www.avast.com
> > <
> https://www.avast.com/fr-fr/lp-safe-emailing?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=OA-2109-A
> >
> > <#DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > 2016-03-11 14:50 GMT+01:00 sebb <sebbaz@gmail.com>:
> >
> >> On 11 March 2016 at 13:25, Antonio Gomes Rodrigues <ra0077@gmail.com>
> >> wrote:
> >> > Hi,
> >> >
> >> > JMeter not skip the missing filename silently (like previously)
> >> >
> >> > But now instead of having an FileNotFoundException exception +
> stacktrace
> >> > we have a clear error message + JMeterStopThreadException
> >> >
> >> > It's more clear for end user
> >> >
> >> > Is it ok?
> >>
> >> It's rather difficult reviewing a patch to a patch.
> >> Is there a URL which shows the complete patch against JMeter trunk?
> >>
> >> > Antonio
> >> >
> >> >
> >> >
> >> > 2016-03-10 18:29 GMT+01:00 Antonio Gomes Rodrigues <ra0077@gmail.com
> >:
> >> >
> >> >> Ok
> >> >>
> >> >> And refactor it to have better log?
> >> >>
> >> >> Cet e-mail a été envoyé depuis un ordinateur protégé par Avast.
> >> >> www.avast.com
> >> >> <
> >>
> https://www.avast.com/fr-fr/lp-esg-fav?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=OA-2109-B
> >> >
> >> >> <#-1759352762_DDB4FAA8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >> >>
> >> >> 2016-03-10 17:52 GMT+01:00 Vladimir Sitnikov <
> >> sitnikov.vladimir@gmail.com>
> >> >> :
> >> >>
> >> >>> sebb>If there is a script file with a working CSV Dataset, and
the
> >> >>> filename
> >> >>> sebb>is accidentally erased, I don't think it's a good idea
to
> continue
> >> >>> sebb>with the test.
> >> >>>
> >> >>> +1
> >> >>>
> >> >>> Vladimir
> >> >>>
> >> >>
> >> >>
> >>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message