Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large request problem #6359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.jorphan.gui.JFactory;
import org.apache.jorphan.gui.JMeterUIDefaults;
import org.apache.jorphan.gui.ui.TextComponentUI;
import org.apache.jorphan.util.StringWrap;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.fife.ui.rsyntaxtextarea.Theme;
Expand Down Expand Up @@ -294,6 +295,30 @@ protected RUndoManager createUndoManager() {
return undoManager;
}

// Default limited to 110K
private static final int MAX_LINE_SIZE =
JMeterUtils.getPropDefault("view.results.tree.max_line_size", 110_000); // $NON-NLS-1$

// Limit the soft wrap to 100K (hard limit divided by 1.1)
private static final int SOFT_WRAP_LINE_SIZE =
JMeterUtils.getPropDefault("view.results.tree.soft_wrap_line_size", (int) (MAX_LINE_SIZE / 1.1f)); // $NON-NLS-1$

private static String wrapLongLines(String input) {
if (input == null || input.isEmpty()) {
return input;
}
if (SOFT_WRAP_LINE_SIZE > 0 && MAX_LINE_SIZE > 0) {
StringWrap stringWrap = new StringWrap(SOFT_WRAP_LINE_SIZE, MAX_LINE_SIZE);
return stringWrap.wrap(input, "\n");
}
return input;
}

@Override
public void setText(String t) {
super.setText(wrapLongLines(t));
}

/**
* Sets initial text resetting undo history
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public String wrap(String input, String delimiter) {
}
// Try adding the next line if it does not exceed maxWrap
int next = nextLineSeparator;
if (next != -1 && pos - next <= maxWrap) {
if (next != -1 && next - pos <= maxWrap) {
// The existing lines do not exceed maxWrap, just reuse them
next++; // include newline
sb.append(input, pos, next);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
public class StringWrapTest {
static Stream<Arguments> data() {
return Stream.of(
arguments(2, 3, "a\nab\nabc\nabcd\nabcde", "a\nab\nabc\nabc|d\nabc|de"),
arguments(2, 2, "0123456789", "01|23|45|67|89"),
arguments(2, 5, "0123456789", "01234|56789"),
arguments(3, 3, "0123456789", "012|345|678|9"),
Expand Down
Loading