Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
ad918c78
Commit
ad918c78
authored
5 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-4048: add debug infos if the error happened
parent
9cddb35c
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/core/gui/media/ServletUtil.java
+19
-17
19 additions, 17 deletions
src/main/java/org/olat/core/gui/media/ServletUtil.java
with
19 additions
and
17 deletions
src/main/java/org/olat/core/gui/media/ServletUtil.java
+
19
−
17
View file @
ad918c78
...
...
@@ -518,7 +518,7 @@ public class ServletUtil {
}
}
public
static
void
serveStringResource
(
HttpServletResponse
response
,
StringOutput
result
)
{
public
static
boolean
serveStringResource
(
HttpServletResponse
response
,
StringOutput
result
)
{
setStringResourceHeaders
(
response
);
// log the response headers prior to sending the output
...
...
@@ -528,30 +528,32 @@ public class ServletUtil {
+
response
.
getCharacterEncoding
()
+
"\nlocale:"
+
response
.
getLocale
());
}
try
{
long
rstart
=
0
;
if
(
isDebug
||
true
)
{
rstart
=
System
.
currentTimeMillis
();
}
try
(
PrintWriter
os
=
response
.
getWriter
();
Reader
reader
=
result
.
getReader
())
{
// make a ByteArrayOutputStream to be able to determine the length.
// buffer size: assume average length of a char in bytes is max 2
int
encLen
=
result
.
length
();
Reader
reader
=
result
.
getReader
();
//response.setContentLength(encLen); set the number of characters, must be number of bytes
PrintWriter
os
=
response
.
getWriter
();
IOUtils
.
copy
(
reader
,
os
);
os
.
close
();
if
(
isDebug
)
{
log
.
debug
(
"time to serve inline-resource "
+
result
.
length
()
+
" chars / "
+
encLen
+
" bytes: "
+
(
System
.
currentTimeMillis
()
-
rstart
));
}
}
catch
(
IllegalStateException
e
)
{
debugIllegalGetOutputStream
(
response
,
result
);
log
.
error
(
"Illegal getWriter"
,
e
);
return
false
;
}
catch
(
IOException
e
)
{
if
(
isDebug
)
{
log
.
warn
(
"client browser abort when serving inline"
,
e
);
}
}
return
true
;
}
private
static
void
debugIllegalGetOutputStream
(
HttpServletResponse
response
,
StringOutput
result
)
{
try
{
for
(
String
header:
response
.
getHeaderNames
())
{
log
.
error
(
"Illegal getWriter: "
+
header
+
" :: "
+
response
.
getHeader
(
header
));
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Illegal getWriter: "
,
e
);
}
log
.
error
(
result
.
toString
());
}
public
static
void
setStringResourceHeaders
(
HttpServletResponse
response
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment