File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
main/java/org/xbill/DNS/hosts
test/java/org/xbill/DNS/hosts Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,12 @@ Do NOT use it.
103103|true
104104|false
105105
106+ .2+|dnsjava.hostsfile.max_size
107+ 3+|Set the size of the hosts file to be loaded at a time,in bytes.
108+ |Integer
109+ |16384
110+ |1000000
111+
106112.2+|dnsjava.nio.selector_timeout
1071133+|Set selector timeout in milliseconds. Default/Max 1000, Min 1.
108114|Integer
Original file line number Diff line number Diff line change 2929 */
3030@ Slf4j
3131public final class HostsFileParser {
32- private static final int MAX_FULL_CACHE_FILE_SIZE_BYTES = Integer .parseInt (
32+
33+ private final int MAX_FULL_CACHE_FILE_SIZE_BYTES = Integer .parseInt (
3334 System .getProperty ("dnsjava.hostsfile.max_size" , "16384" ));
3435
3536 private final Map <String , InetAddress > hostsCache = new HashMap <>();
Original file line number Diff line number Diff line change @@ -171,6 +171,17 @@ void testBigFileIsNotCompletelyCachedA() throws IOException {
171171 assertEquals (1 , hostsFileParser .cacheSize ());
172172 }
173173
174+ @ Test
175+ void testBigFileCompletelyCachedA () throws IOException {
176+ System .setProperty ("dnsjava.hostsfile.max_size" , 1024 * 1024 * 1024 + "" );
177+ HostsFileParser hostsFileParser = generateLargeHostsFile ("testBigFileCompletelyCachedA" );
178+ hostsFileParser
179+ .getAddressForHost (Name .fromConstantString ("localhost-10." ), Type .A )
180+ .orElseThrow (() -> new IllegalStateException ("Host entry not found" ));
181+ assertEquals (1280 , hostsFileParser .cacheSize ());
182+ System .clearProperty ("dnsjava.hostsfile.max_size" );
183+ }
184+
174185 @ Test
175186 void testBigFileIsNotCompletelyCachedAAAA () throws IOException {
176187 HostsFileParser hostsFileParser =
You can’t perform that action at this time.
0 commit comments