• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / sitemesh2 / 59

22 Mar 2026 02:30AM UTC coverage: 40.347%. Remained the same
59

push

github

hazendaz
[mvn] Update maven wrapper

698 of 1891 branches covered (36.91%)

Branch coverage included in aggregate %.

1555 of 3693 relevant lines covered (42.11%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/opensymphony/module/sitemesh/filter/DebugResponseWrapper.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
/* This software is published under the terms of the OpenSymphony Software
6
 * License version 1.1, of which a copy has been included with this
7
 * distribution in the LICENSE.txt file. */
8
package com.opensymphony.module.sitemesh.filter;
9

10
import jakarta.servlet.ServletOutputStream;
11
import jakarta.servlet.http.Cookie;
12
import jakarta.servlet.http.HttpServletResponse;
13
import jakarta.servlet.http.HttpServletResponseWrapper;
14

15
import java.io.IOException;
16
import java.io.PrintWriter;
17
import java.util.Locale;
18

19
import org.slf4j.Logger;
20
import org.slf4j.LoggerFactory;
21

22
/**
23
 * The Class DebugResponseWrapper.
24
 *
25
 * @author <a href="joe@truemesh.com">Joe Walnes</a>
26
 */
27
public class DebugResponseWrapper extends HttpServletResponseWrapper {
28

29
    /** The Logger. */
30
    private static final Logger logger = LoggerFactory.getLogger(DebugResponseWrapper.class);
×
31

32
    /** The last count. */
33
    private static int lastCount;
34

35
    /** The count. */
36
    private int count;
37

38
    /**
39
     * Instantiates a new debug response wrapper.
40
     *
41
     * @param response
42
     *            the response
43
     */
44
    public DebugResponseWrapper(HttpServletResponse response) {
45
        super(response);
×
46
        if (enabled()) {
×
47
            lastCount++;
×
48
            count = lastCount;
×
49
            debug("<CONSTRUCT>", null, null);
×
50
        }
51
    }
×
52

53
    @Override
54
    public void addCookie(Cookie cookie) {
55
        if (enabled()) {
×
56
            debug("addCookie", cookie.getName(), cookie.toString());
×
57
        }
58
        super.addCookie(cookie);
×
59
    }
×
60

61
    @Override
62
    public void addDateHeader(String name, long date) {
63
        if (enabled()) {
×
64
            debug("addDateHeader", name, String.valueOf(date));
×
65
        }
66
        super.addDateHeader(name, date);
×
67
    }
×
68

69
    @Override
70
    public void addHeader(String name, String value) {
71
        if (enabled()) {
×
72
            debug("addHeader", name, value);
×
73
        }
74
        super.addHeader(name, value);
×
75
    }
×
76

77
    @Override
78
    public void addIntHeader(String name, int value) {
79
        if (enabled()) {
×
80
            debug("addIntHeader", name, String.valueOf(value));
×
81
        }
82
        super.addIntHeader(name, value);
×
83
    }
×
84

85
    @Override
86
    public boolean containsHeader(String name) {
87
        return super.containsHeader(name);
×
88
    }
89

90
    @Override
91
    public String encodeRedirectURL(String url) {
92
        return super.encodeRedirectURL(url);
×
93
    }
94

95
    @Override
96
    public void sendError(int sc) throws IOException {
97
        if (enabled()) {
×
98
            debug("sendError", String.valueOf(sc), null);
×
99
        }
100
        super.sendError(sc);
×
101
    }
×
102

103
    @Override
104
    public void sendError(int sc, String msg) throws IOException {
105
        if (enabled()) {
×
106
            debug("sendError", String.valueOf(sc), msg);
×
107
        }
108
        super.sendError(sc, msg);
×
109
    }
×
110

111
    @Override
112
    public void sendRedirect(String location) throws IOException {
113
        if (enabled()) {
×
114
            debug("sendRedirect", location, null);
×
115
        }
116
        super.sendRedirect(location);
×
117
    }
×
118

119
    @Override
120
    public void setDateHeader(String name, long date) {
121
        if (enabled()) {
×
122
            debug("setDateHeader", name, String.valueOf(date));
×
123
        }
124
        super.setDateHeader(name, date);
×
125
    }
×
126

127
    @Override
128
    public void setHeader(String name, String value) {
129
        if (enabled()) {
×
130
            debug("setHeader", name, value);
×
131
        }
132
        super.setHeader(name, value);
×
133
    }
×
134

135
    @Override
136
    public void setIntHeader(String name, int value) {
137
        if (enabled()) {
×
138
            debug("setIntHeader", name, String.valueOf(value));
×
139
        }
140
        super.setIntHeader(name, value);
×
141
    }
×
142

143
    @Override
144
    public void setStatus(int sc) {
145
        if (enabled()) {
×
146
            debug("setStatus", String.valueOf(sc), null);
×
147
        }
148
        super.setStatus(sc);
×
149
    }
×
150

151
    @Override
152
    public void flushBuffer() throws IOException {
153
        if (enabled()) {
×
154
            debug("flushBuffer", null, null);
×
155
        }
156
        super.flushBuffer();
×
157
    }
×
158

159
    @Override
160
    public int getBufferSize() {
161
        //
162
        return super.getBufferSize();
×
163
    }
164

165
    @Override
166
    public String getCharacterEncoding() {
167
        //
168
        return super.getCharacterEncoding();
×
169
    }
170

171
    @Override
172
    public Locale getLocale() {
173
        //
174
        return super.getLocale();
×
175
    }
176

177
    @Override
178
    public ServletOutputStream getOutputStream() throws IOException {
179
        if (enabled()) {
×
180
            debug("getOutputStream", null, null);
×
181
        }
182
        return super.getOutputStream();
×
183
    }
184

185
    @Override
186
    public PrintWriter getWriter() throws IOException {
187
        if (enabled()) {
×
188
            debug("getWriter", null, null);
×
189
        }
190
        return super.getWriter();
×
191
    }
192

193
    @Override
194
    public boolean isCommitted() {
195
        //
196
        return super.isCommitted();
×
197
    }
198

199
    @Override
200
    public void reset() {
201
        if (enabled()) {
×
202
            debug("reset", null, null);
×
203
        }
204
        super.reset();
×
205
    }
×
206

207
    /*
208
     * public void resetBuffer() { super.resetBuffer(); }
209
     */
210

211
    @Override
212
    public void setBufferSize(int size) {
213
        if (enabled()) {
×
214
            debug("setBufferSize", String.valueOf(size), null);
×
215
        }
216
        super.setBufferSize(size);
×
217
    }
×
218

219
    @Override
220
    public void setContentLength(int len) {
221
        if (enabled()) {
×
222
            debug("setContentLength", String.valueOf(len), null);
×
223
        }
224
        super.setContentLength(len);
×
225
    }
×
226

227
    @Override
228
    public void setContentType(String type) {
229
        if (enabled()) {
×
230
            debug("setContentType", type, null);
×
231
        }
232
        super.setContentType(type);
×
233
    }
×
234

235
    @Override
236
    public void setLocale(Locale locale) {
237
        if (enabled()) {
×
238
            debug("setBufferSize", locale.getDisplayName(), null);
×
239
        }
240
        super.setLocale(locale);
×
241
    }
×
242

243
    /**
244
     * Enabled.
245
     *
246
     * @return true, if successful
247
     */
248
    private boolean enabled() {
249
        return true;
×
250
    }
251

252
    /**
253
     * Debug.
254
     *
255
     * @param methodName
256
     *            the method name
257
     * @param arg1
258
     *            the arg 1
259
     * @param arg2
260
     *            the arg 2
261
     */
262
    private void debug(String methodName, String arg1, String arg2) {
263
        StringBuilder s = new StringBuilder();
×
264
        s.append("[debug ");
×
265
        s.append(count);
×
266
        s.append("] ");
×
267
        s.append(methodName);
×
268
        s.append("()");
×
269
        if (arg1 != null) {
×
270
            s.append(" : '");
×
271
            s.append(arg1);
×
272
            s.append("'");
×
273
        }
274
        if (arg2 != null) {
×
275
            s.append(" = '");
×
276
            s.append(arg2);
×
277
            s.append("'");
×
278
        }
279
        logger.info("{}", s);
×
280
    }
×
281
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc