<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Java on Prateek Sharma</title>
		<link>https://prateeksharma.me/tags/java/</link>
		<description>Recent content in Java on Prateek Sharma</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Sat, 29 Aug 2026 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://prateeksharma.me/tags/java/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Daemon threads for WebSocket keepalives</title>
				<link>https://prateeksharma.me/notes/daemon-threads-for-websocket-keepalives/</link>
				<pubDate>Sat, 29 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/notes/daemon-threads-for-websocket-keepalives/</guid>
				<description>&lt;p&gt;A WebSocket connection that needs periodic pings to stay open shouldn&amp;rsquo;t run that&#xA;ping loop on a plain, non-daemon thread. In the&#xA;&lt;a href=&#34;https://prateeksharma.me/projects/wazirx-connector-java/&#34;&gt;WazirX Java connector&lt;/a&gt;&#xA;, the ping thread is&#xA;started &lt;code&gt;onOpen&lt;/code&gt; and marked &lt;code&gt;setDaemon(true)&lt;/code&gt; before starting it:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#e6edf3;background-color:#0d1117;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-java&#34; data-lang=&#34;java&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pingThread&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#ff7b72;font-weight:bold&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;&lt;span style=&#34;color:#ff7b72&#34;&gt;new&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;Thread(&lt;span style=&#34;color:#ff7b72&#34;&gt;new&lt;/span&gt;&lt;span style=&#34;color:#6e7681&#34;&gt; &lt;/span&gt;PingMessage(&lt;span style=&#34;color:#ff7b72&#34;&gt;this&lt;/span&gt;));&lt;span style=&#34;color:#6e7681&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pingThread.setDaemon(&lt;span style=&#34;color:#79c0ff&#34;&gt;true&lt;/span&gt;);&lt;span style=&#34;color:#6e7681&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;pingThread.start();&lt;span style=&#34;color:#6e7681&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A non-daemon thread keeps the JVM alive until it finishes. If a caller opens a&#xA;socket, forgets to close it, and the rest of the application shuts down, a&#xA;non-daemon ping thread will keep the process running indefinitely. A daemon&#xA;thread just gets killed when everything else is done — which is the right&#xA;default for background keepalive work that isn&amp;rsquo;t itself the point of the&#xA;program.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Give callers two error types, one extending the other</title>
				<link>https://prateeksharma.me/opinions/two-exceptions-not-one/</link>
				<pubDate>Fri, 28 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/opinions/two-exceptions-not-one/</guid>
				<description>&lt;p&gt;In the &lt;a href=&#34;https://prateeksharma.me/projects/wazirx-connector-java/&#34;&gt;WazirX Java connector&lt;/a&gt;&#xA; I split errors&#xA;into two:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;WazirxClientException&lt;/code&gt; — the caller made a mistake the caller can fix: a bad&#xA;&lt;code&gt;side&lt;/code&gt; value, a missing required field. Thrown before a request is even sent.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;WazirxApiException&lt;/code&gt; — something went wrong once the request left the process:&#xA;a network failure, a non-2xx response.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;code&gt;WazirxClientException extends WazirxApiException&lt;/code&gt;. That one line is the whole&#xA;design. A caller who only cares &amp;ldquo;did this work?&amp;rdquo; catches the parent. A caller who&#xA;wants to retry network failures but fail fast on their own bad input catches both&#xA;separately. Nobody is forced into a giant &lt;code&gt;catch (Exception e)&lt;/code&gt; that swallows&#xA;bugs, and nobody has to &lt;code&gt;try/catch&lt;/code&gt; five specific types at every call site.&lt;/p&gt;</description>
			</item>
			<item>
				<title>WazirX Java Connector</title>
				<link>https://prateeksharma.me/projects/wazirx-connector-java/</link>
				<pubDate>Sun, 23 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/projects/wazirx-connector-java/</guid>
				<description>&lt;p&gt;After building the &lt;a href=&#34;https://prateeksharma.me/projects/wazirx-connector-go/&#34;&gt;Go connector&lt;/a&gt;&#xA; for WazirX, I&#xA;wanted the same thing on the JVM — but WazirX doesn&amp;rsquo;t publish an official Java&#xA;client at all, REST or WebSocket. The REST half was a fairly direct port of what&#xA;I&amp;rsquo;d already learned building the Go client. The WebSocket half turned out to be&#xA;its own project.&lt;/p&gt;&#xA;&lt;h2 id=&#34;letting-callers-choose-their-failure-granularity&#34;&gt;Letting callers choose their failure granularity&lt;/h2&gt;&#xA;&lt;p&gt;For errors, I didn&amp;rsquo;t want every caller forced into one giant catch-all&#xA;exception, but I also didn&amp;rsquo;t want to force a &lt;code&gt;try/catch&lt;/code&gt; at every single call&#xA;site. I split errors into two, with one extending the other:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Adda52 — Delta Corp</title>
				<link>https://prateeksharma.me/experience/adda52/</link>
				<pubDate>Mon, 01 Sep 2014 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/experience/adda52/</guid>
				<description>&lt;p&gt;Adda52 is one of India&amp;rsquo;s largest real-money poker platforms. I joined as a&#xA;graduate trainee in 2014 and left in 2020 as a Senior Software Engineer, working&#xA;across the game backend, load and resilience testing, and the public platform.&lt;/p&gt;&#xA;&lt;h2 id=&#34;role-progression&#34;&gt;Role progression&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Graduate Engineer Trainee&lt;/strong&gt; (Sep 2014 – Oct 2015)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Software Engineer&lt;/strong&gt; (Oct 2015 – Oct 2016)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Senior Software Engineer&lt;/strong&gt; (Oct 2016 – Feb 2020)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;engineering-areas&#34;&gt;Engineering areas&lt;/h2&gt;&#xA;&lt;h3 id=&#34;game-logic&#34;&gt;Game logic&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Contributed to core poker cash-game and tournament-management modules.&lt;/li&gt;&#xA;&lt;li&gt;Implemented the &lt;strong&gt;OFC&lt;/strong&gt; poker variant end to end on the &lt;code&gt;adda52live.com&lt;/code&gt;&#xA;frontend (Angular 2).&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;load-and-resilience-testing&#34;&gt;Load and resilience testing&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Enhanced Java-based user-behaviour simulators to &lt;strong&gt;load test real-time poker&#xA;servers at 10,000+ concurrent users&lt;/strong&gt;.&lt;/li&gt;&#xA;&lt;li&gt;Built &lt;strong&gt;disaster-recovery systems&lt;/strong&gt; for zero-downtime gameplay — restoring&#xA;poker games and player state after a failure.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;platform-migration&#34;&gt;Platform migration&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Led migration of the public gaming platform from &lt;strong&gt;PHP to Node.js&lt;/strong&gt;, improving&#xA;performance and maintainability.&lt;/li&gt;&#xA;&lt;li&gt;Built Angular 2 interfaces for event bookings on &lt;code&gt;adda52live.com&lt;/code&gt; and&#xA;user-segmentation logic for targeted marketing.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;delivery&#34;&gt;Delivery&lt;/h3&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Developed Gradle-based CI/CD pipelines with &lt;strong&gt;Jenkins&lt;/strong&gt;, automating builds and&#xA;reducing integration friction.&lt;/li&gt;&#xA;&lt;li&gt;Represented a 6-member team in sprint planning and stakeholder meetings,&#xA;coordinating with QA, product, and DevOps.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;stack&#34;&gt;Stack&lt;/h2&gt;&#xA;&lt;p&gt;Java · Node.js · Angular 2 · Jenkins · Gradle&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
