• 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/RoutableServletOutputStream.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.WriteListener;
12

13
import java.io.IOException;
14

15
/**
16
 * Provides a ServletOutputStream that routes through to another ServletOutputStream, however the destination can be
17
 * changed at any point. The destination can be passed in using a factory, so it will not be created until it's actually
18
 * needed.
19
 *
20
 * @author Joe Walnes
21
 */
22
public class RoutableServletOutputStream extends ServletOutputStream {
23

24
    /** The destination. */
25
    private ServletOutputStream destination;
26

27
    /** The factory. */
28
    private DestinationFactory factory;
29

30
    /**
31
     * Factory to lazily instantiate the destination.
32
     */
33
    public interface DestinationFactory {
34

35
        /**
36
         * Creates the.
37
         *
38
         * @return the servlet output stream
39
         *
40
         * @throws IOException
41
         *             Signals that an I/O exception has occurred.
42
         */
43
        ServletOutputStream create() throws IOException;
44
    }
45

46
    /**
47
     * Instantiates a new routable servlet output stream.
48
     *
49
     * @param factory
50
     *            the factory
51
     */
52
    public RoutableServletOutputStream(DestinationFactory factory) {
×
53
        this.factory = factory;
×
54
    }
×
55

56
    /**
57
     * Gets the destination.
58
     *
59
     * @return the destination
60
     *
61
     * @throws IOException
62
     *             Signals that an I/O exception has occurred.
63
     */
64
    private ServletOutputStream getDestination() throws IOException {
65
        if (destination == null) {
×
66
            destination = factory.create();
×
67
        }
68
        return destination;
×
69
    }
70

71
    /**
72
     * Update destination.
73
     *
74
     * @param factory
75
     *            the factory
76
     */
77
    public void updateDestination(DestinationFactory factory) {
78
        destination = null;
×
79
        this.factory = factory;
×
80
    }
×
81

82
    @Override
83
    public void close() throws IOException {
84
        getDestination().close();
×
85
    }
×
86

87
    @Override
88
    public void write(int b) throws IOException {
89
        getDestination().write(b);
×
90
    }
×
91

92
    @Override
93
    public void print(String s) throws IOException {
94
        getDestination().print(s);
×
95
    }
×
96

97
    @Override
98
    public void print(boolean b) throws IOException {
99
        getDestination().print(b);
×
100
    }
×
101

102
    @Override
103
    public void print(char c) throws IOException {
104
        getDestination().print(c);
×
105
    }
×
106

107
    @Override
108
    public void print(int i) throws IOException {
109
        getDestination().print(i);
×
110
    }
×
111

112
    @Override
113
    public void print(long l) throws IOException {
114
        getDestination().print(l);
×
115
    }
×
116

117
    @Override
118
    public void print(float v) throws IOException {
119
        getDestination().print(v);
×
120
    }
×
121

122
    @Override
123
    public void print(double v) throws IOException {
124
        getDestination().print(v);
×
125
    }
×
126

127
    @Override
128
    public void println() throws IOException {
129
        getDestination().println();
×
130
    }
×
131

132
    @Override
133
    public void println(String s) throws IOException {
134
        getDestination().println(s);
×
135
    }
×
136

137
    @Override
138
    public void println(boolean b) throws IOException {
139
        getDestination().println(b);
×
140
    }
×
141

142
    @Override
143
    public void println(char c) throws IOException {
144
        getDestination().println(c);
×
145
    }
×
146

147
    @Override
148
    public void println(int i) throws IOException {
149
        getDestination().println(i);
×
150
    }
×
151

152
    @Override
153
    public void println(long l) throws IOException {
154
        getDestination().println(l);
×
155
    }
×
156

157
    @Override
158
    public void println(float v) throws IOException {
159
        getDestination().println(v);
×
160
    }
×
161

162
    @Override
163
    public void println(double v) throws IOException {
164
        getDestination().println(v);
×
165
    }
×
166

167
    @Override
168
    public void write(byte b[]) throws IOException {
169
        getDestination().write(b);
×
170
    }
×
171

172
    @Override
173
    public void write(byte b[], int off, int len) throws IOException {
174
        getDestination().write(b, off, len);
×
175
    }
×
176

177
    @Override
178
    public void flush() throws IOException {
179
        getDestination().flush();
×
180
    }
×
181

182
    @Override
183
    public boolean isReady() {
184
        return false;
×
185
    }
186

187
    @Override
188
    public void setWriteListener(WriteListener writeListener) {
189
        // TODO Not Implemented
190
    }
×
191
}
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