Skip to content

Commit

Permalink
Merge pull request #8 from kbrandt/master
Browse files Browse the repository at this point in the history
[FIXED JENKINS-14255] java.io.InvalidClassException
  • Loading branch information
kbrandt committed Nov 13, 2012
2 parents fa00c93 + f2577af commit 098949d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
37 changes: 18 additions & 19 deletions src/main/java/hudson/plugins/sloccount/SloccountPublisher.java
Expand Up @@ -46,33 +46,32 @@ protected boolean canContinue(final Result result) {

@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener){

SloccountResult result;

FilePath workspace = build.getWorkspace();
PrintStream logger = listener.getLogger();
SloccountReport report = new SloccountReport();
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger, report);
SloccountParser parser = new SloccountParser(this.getRealEncoding(), this.getRealPattern(), logger);
SloccountReport report;

if(this.canContinue(build.getResult())){

try{
FilePath workspace = build.getWorkspace();
try{
if(this.canContinue(build.getResult())){
report = workspace.act(parser);

}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}else{
// generate an empty report
// TODO: Replace this empty report with the last valid one?
report = new SloccountReport();
}

}else{

// continue with empty report object
}catch(IOException ioe){
ioe.printStackTrace(logger);
return false;

}catch(InterruptedException ie){
ie.printStackTrace(logger);
return false;
}

result = new SloccountResult(report, build);

SloccountBuildAction buildAction = new SloccountBuildAction(build, result);
Expand Down
Expand Up @@ -21,27 +21,26 @@ public class SloccountParser implements FilePath.FileCallable<SloccountReport> {
private final String encoding;
private final String filePattern;
private transient PrintStream logger = null;
private transient SloccountReport report = null;

public SloccountParser(String encoding, String filePattern, PrintStream logger, SloccountReport report){
this.report = report;
public SloccountParser(String encoding, String filePattern, PrintStream logger){
this.logger = logger;
this.filePattern = filePattern;
this.encoding = encoding;
}


public SloccountReport invoke(java.io.File workspace, VirtualChannel channel) throws IOException {
SloccountReport report = new SloccountReport();

FileFinder finder = new FileFinder(this.filePattern);
String[] found = finder.find(workspace);

for(String fileName : found){
this.parse(workspace, fileName, this.report);
this.parse(workspace, fileName, report);
}

this.report.simplifyNames();
return this.report;
report.simplifyNames();
return report;
}

private void parse(java.io.File workspace, String fileName, SloccountReport report) throws IOException {
Expand Down Expand Up @@ -86,9 +85,9 @@ private void parseLine(String line, SloccountReport report){
if(LOG_ENABLED && (this.logger != null)){
logger.println("lineCount: " + lineCount);
logger.println("language : " + languageName);
logger.println("file : " + filePath);
logger.println("file : " + filePath);
}

report.add(filePath, languageName, lineCount);
}
}
}

0 comments on commit 098949d

Please sign in to comment.