Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SONAR-6277 Replace ReportStream by CloseableIterator and remove FileS…
…tream (IOUtils.lineIterator should be used instead)
- Loading branch information
1 parent
5904b95
commit a18f0a9
Showing
11 changed files
with
129 additions
and
401 deletions.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
server/sonar-server/src/main/java/org/sonar/server/computation/source/ReportIterator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* SonarQube, open source software quality management tool. | ||
* Copyright (C) 2008-2014 SonarSource | ||
* mailto:contact AT sonarsource DOT com | ||
* | ||
* SonarQube is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* SonarQube is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
package org.sonar.server.computation.source; | ||
|
||
import com.google.common.base.Throwables; | ||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import com.google.protobuf.Parser; | ||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.IOUtils; | ||
import org.sonar.server.util.CloseableIterator; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
public class ReportIterator<E> extends CloseableIterator<E> { | ||
|
||
private final Parser<E> parser; | ||
private InputStream stream; | ||
|
||
public ReportIterator(File file, Parser<E> parser) { | ||
try { | ||
this.parser = parser; | ||
this.stream = FileUtils.openInputStream(file); | ||
} catch (IOException e) { | ||
throw Throwables.propagate(e); | ||
} | ||
} | ||
|
||
@Override | ||
protected E doNext() { | ||
try { | ||
return parser.parseDelimitedFrom(stream); | ||
} catch (InvalidProtocolBufferException e) { | ||
throw Throwables.propagate(e); | ||
} | ||
} | ||
|
||
@Override | ||
protected void doClose() { | ||
IOUtils.closeQuietly(stream); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/FileStream.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 0 additions & 108 deletions
108
sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/ReportStream.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.