use of org.thymeleaf.exceptions.TemplateOutputException in project thymeleaf by thymeleaf.
the class ThrottledTemplateWriterWriterAdapter method allow.
public void allow(final int limit) {
if (limit == Integer.MAX_VALUE || limit < 0) {
this.unlimited = true;
this.limit = -1;
} else {
this.unlimited = false;
this.limit = limit;
}
this.flowController.stopProcessing = (this.limit == 0);
if (this.overflowSize == 0 || this.limit == 0) {
return;
}
try {
if (this.unlimited || this.limit > this.overflowSize) {
this.writer.write(this.overflow, 0, this.overflowSize);
if (!this.unlimited) {
this.limit -= this.overflowSize;
}
this.writtenCount += this.overflowSize;
this.overflowSize = 0;
return;
}
this.writer.write(this.overflow, 0, this.limit);
if (this.limit < this.overflowSize) {
System.arraycopy(this.overflow, this.limit, this.overflow, 0, this.overflowSize - this.limit);
}
this.overflowSize -= this.limit;
this.writtenCount += this.limit;
this.limit = 0;
this.flowController.stopProcessing = true;
} catch (final IOException e) {
throw new TemplateOutputException("Exception while trying to write overflowed buffer in throttled template", this.templateName, -1, -1, e);
}
}
Aggregations