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

aspectran / aspectran / #3971

08 Jan 2025 12:17PM CUT coverage: 35.017% (-0.009%) from 35.026%
#3971

push

github

topframe
Update

8 of 27 new or added lines in 6 files covered. (29.63%)

7 existing lines in 5 files now uncovered.

14188 of 40517 relevant lines covered (35.02%)

0.35 hits per line

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

58.82
/with-undertow/src/main/java/com/aspectran/undertow/server/DefaultTowServer.java
1
/*
2
 * Copyright (c) 2008-2025 The Aspectran Project
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.aspectran.undertow.server;
17

18
import com.aspectran.core.component.bean.ablility.DisposableBean;
19
import com.aspectran.core.component.bean.ablility.InitializableBean;
20
import com.aspectran.utils.logging.Logger;
21
import com.aspectran.utils.logging.LoggerFactory;
22
import io.undertow.Undertow;
23

24
/**
25
 * The Undertow Server managed by Aspectran.
26
 *
27
 * @see <a href="http://undertow.io">Undertow</a>
28
 * @since 6.3.0
29
 */
30
public class DefaultTowServer extends AbstractTowServer implements InitializableBean, DisposableBean {
1✔
31

32
    private static final Logger logger = LoggerFactory.getLogger(DefaultTowServer.class);
1✔
33

34
    private Undertow server;
35

36
    @Override
37
    public void doStart() throws Exception {
38
        try {
39
            server = buildServer();
1✔
40
            server.start();
1✔
41
            logger.info("Undertow " + TowServer.getVersion() + " started");
1✔
42
        } catch (Exception e) {
×
NEW
43
            if (server != null) {
×
44
                try {
45
                    server.stop();
×
NEW
46
                } catch (Exception ex) {
×
47
                    // ignore
48
                }
×
NEW
49
                server = null;
×
50
            }
51
            throw new Exception("Unable to start Undertow server", e);
×
52
        }
1✔
53
    }
1✔
54

55
    @Override
56
    public void doStop() {
57
        try {
58
            shutdown();
1✔
NEW
59
        } catch (Exception e) {
×
NEW
60
            logger.error("TowServer shutdown failed", e);
×
61
        }
1✔
62
        if (server != null) {
1✔
63
            try {
64
                server.stop();
1✔
65
                logger.info("Undertow " + TowServer.getVersion() + " stopped");
1✔
UNCOV
66
            } catch (Exception e) {
×
67
                logger.error("Unable to stop Undertow server", e);
×
68
            }
1✔
69
            server = null;
1✔
70
        }
71
    }
1✔
72

73
    @Override
74
    public void initialize() throws Exception {
75
        if (isAutoStart()) {
1✔
76
            start();
×
77
        }
78
    }
1✔
79

80
    @Override
81
    public void destroy() {
82
        try {
83
            stop();
1✔
84
        } catch (Exception e) {
×
85
            logger.error("Error while stopping Undertow server", e);
×
86
        }
1✔
87
    }
1✔
88

89
}
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

© 2025 Coveralls, Inc