DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Coding
  3. Java
  4. Undocumented Oracle JVM HttpServer Properties

Undocumented Oracle JVM HttpServer Properties

Dustin Marx user avatar by
Dustin Marx
·
Jul. 30, 12 · Interview
Like (0)
Save
Tweet
Share
3.78K Views

Join the DZone community and get the full member experience.

Join For Free

I have blogged before on the utility of the HttpServer provided with the Oracle HotSpot JVM. One of the general challenges associated with its use is the lack of documentation. Fortunately, its open source implementation allows certain features to be discovered. In this post, I look at some apparently undocumented properties that are used by the HttpServer's source code.

A colleague (thanks Jim!) pointed out the existence of these properties as discovered in the source code. There are multiple places from which the relevant source code can be acquired and reviewed. One easily accessible location is Docjar. For example, the code listings for sun.net.httpserver.ServerConfig and sun.net.httpserver.ServerImpl are hosted there. Other similar sites include Open Source Java Code (ServerConfig) and grepcode (ServerConfig).

The static initialization block of the sun.net.httpserver.ServerConfig class includes the setting of several static variables based on specific Java properties or based on a default if no property is provided. The next code listing comes from that class and indicates the default values for these static variables.

static final int DEFAULT_CLOCK_TICK = 10000 ; // 10 sec.

/* These values must be a reasonable multiple of clockTick */
static final long DEFAULT_IDLE_INTERVAL = 30 ; // 5 min
static final int DEFAULT_MAX_IDLE_CONNECTIONS = 200 ;

static final long DEFAULT_MAX_REQ_TIME = -1; // default: forever
static final long DEFAULT_MAX_RSP_TIME = -1; // default: forever
static final long DEFAULT_TIMER_MILLIS = 1000;

static final long DEFAULT_DRAIN_AMOUNT = 64 * 1024;

As the code and comments above indicate, the default idle interval is 300 seconds (5 minutes). The default request and response times are "forever" indicated by -1.

Although defaults are available as indicated in the above code listing, these can be overridden via the specification of Java properties. These properties are not well documented, but can be gleaned from the code. The following is a list of them as extracted from the ServerConfig class with notes about each property based on other portions of the code.

Properties for Configuring HotSpot HttpServer
  • sun.net.httpserver.idleInterval
  • sun.net.httpserver.clockTick
  • sun.net.httpserver.maxIdleConnections
  • sun.net.httpserver.drainAmount
  • sun.net.httpserver.maxReqTime
    • Replaces sun.net.httpserver.readTimeout
  • sun.net.httpserver.maxRspTime
    • Replaces sun.net.httpserver.writeTimeout
  • sun.net.httpserver.timerMillis
  • sun.net.httpserver.debug

Note that the property sun.net.httpserver.selCacheTimeout is no longer used, but does not have its replacement spelled out in the code comments or logged messages.

The Oracle JVM HttpServer allows for configuration based on Java properties. These properties are not well advertised, but the open source nature of the HttpServer implementation makes it possible to browse the code to determine which properties are available.

 

 

Java (programming language) Java virtual machine Property (programming) Open source code style

Published at DZone with permission of Dustin Marx, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • API Design Patterns Review
  • Tech Layoffs [Comic]
  • RabbitMQ vs. Memphis.dev
  • Top 5 PHP REST API Frameworks

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: