Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristopher Frost2012-10-17 13:13:02 -0400
committerChristopher Frost2012-10-17 13:13:02 -0400
commitc4b02ece8d54d63d33008276d00bae0968fc21d2 (patch)
treedb83cb5e69c51a55b6b3055482d12209183797d0
parentf12bdbb7fa1233cb697ac8cc4c6e867c39cad9e2 (diff)
downloadorg.eclipse.virgo.medic-c4b02ece8d54d63d33008276d00bae0968fc21d2.tar.gz
org.eclipse.virgo.medic-c4b02ece8d54d63d33008276d00bae0968fc21d2.tar.xz
org.eclipse.virgo.medic-c4b02ece8d54d63d33008276d00bae0968fc21d2.zip
388201 Adding truncation for files over 1MB for dump entry streaming
-rw-r--r--org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
index ce2d605..df43f64 100644
--- a/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
+++ b/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/management/FileSystemDumpInspector.java
@@ -11,9 +11,11 @@
package org.eclipse.virgo.medic.management;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.LineNumberReader;
+import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -34,6 +36,8 @@ import org.eclipse.virgo.util.io.FileSystemUtils;;
public class FileSystemDumpInspector implements DumpInspector {
private static final String OSGI_STATE_STRING = "OSGi-state";
+
+ private static final long LARGE_FILE_SIZE_LIMIT = 1024000l;
private final Logger logger = LoggerFactory.getLogger(FileSystemDumpInspector.class);
@@ -110,10 +114,14 @@ public class FileSystemDumpInspector implements DumpInspector {
if(dumpDir != null && dumpDir.exists() && dumpDir.isDirectory()){
File dumpEntry = new File(dumpDir, dumpId + File.separatorChar + entryName);
if(dumpEntry != null){
- LineNumberReader reader = null;
+ RandomAccessFile reader = null;
try {
- reader = new LineNumberReader(new FileReader(dumpEntry));
- while (reader.ready()){
+ reader = new RandomAccessFile(dumpEntry, "r");
+ while (reader.getFilePointer() < reader.length()){
+ if(reader.getFilePointer() > LARGE_FILE_SIZE_LIMIT){
+ lines.add("File exceeds 1MB, truncated.");
+ break;
+ }
String rawLine = reader.readLine();
if(rawLine != null){
lines.add(this.escapeAngleBrackets(rawLine));

Back to the top