Debian Codegraph @

minidns-client/src/main/java/org/minidns/MiniDnsInitialization.java

raw
1 /*
2 * Copyright 2015-2020 the original author or authors
3 *
4 * This software is licensed under the Apache License, Version 2.0,
5 * the GNU Lesser General Public License version 2 or later ("LGPL")
6 * and the WTFPL.
7 * You may choose either license to govern your use of this software only
8 * upon the condition that you accept all of the terms of either
9 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
10 */
11 package org.minidns;
12
13 import java.io.BufferedReader;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import java.io.InputStreamReader;
17 import java.nio.charset.StandardCharsets;
18 import java.util.logging.Level;
19 import java.util.logging.Logger;
20
21 public class MiniDnsInitialization {
22
23 private static final Logger LOGGER = Logger.getLogger(MiniDnsInitialization.class.getName());
24
25 static final String VERSION;
26
27 static {
28 String miniDnsVersion;
29 BufferedReader reader = null;
30 try {
31 InputStream is = MiniDnsInitialization.class.getClassLoader().getResourceAsStream("org.minidns/version");
32 reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
33 miniDnsVersion = reader.readLine();
34 } catch (Exception e) {
35 LOGGER.log(Level.SEVERE, "Could not determine MiniDNS version", e);
36 miniDnsVersion = "unkown";
37 } finally {
38 if (reader != null) {
39 try {
40 reader.close();
41 } catch (IOException e) {
42 LOGGER.log(Level.WARNING, "IOException closing stream", e);
43 }
44 }
45 }
46 VERSION = miniDnsVersion;
47 }
48 }