<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Prudhvi Donempudi on Medium]]></title>
        <description><![CDATA[Stories by Prudhvi Donempudi on Medium]]></description>
        <link>https://medium.com/@don-prudhvi?source=rss-ad4f6aeca62c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*puta4_WPY9xBCLEIvvYaJA.jpeg</url>
            <title>Stories by Prudhvi Donempudi on Medium</title>
            <link>https://medium.com/@don-prudhvi?source=rss-ad4f6aeca62c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:22:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@don-prudhvi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Singleton Design Pattern]]></title>
            <link>https://medium.com/@don-prudhvi/singleton-design-pattern-d854bd648d77?source=rss-ad4f6aeca62c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d854bd648d77</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[singleton-design-pattern]]></category>
            <category><![CDATA[singleton-pattern]]></category>
            <dc:creator><![CDATA[Prudhvi Donempudi]]></dc:creator>
            <pubDate>Wed, 11 Nov 2026 07:25:27 GMT</pubDate>
            <atom:updated>2026-11-11T07:25:27.135Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>Creational design pattern</li><li>Guarantees that a class has only single instance in the application</li><li>Provides a global access point to the application for the instance</li></ul><h3>When a class is called singleton</h3><ul><li>One private constructor — so that no one call initialise the instance using new keyword</li><li>Static method that hands out the shared instance</li></ul><h3>Top use cases of singleton pattern.</h3><ul><li>Loggers</li><li>Connection pool managers</li><li>Thread pool managers</li><li>Configuration holders</li><li>Caches</li><li>Registries</li></ul><h3>Implementations in Java</h3><p><strong>1. Eager initialization</strong></p><pre>public class Config{<br>        private static final Config instance = new Config();<br>        private Config(){}<br>        public static Config getInstance(){<br>            return instance;<br>        }<br>    }</pre><p><strong>Pros</strong>:</p><ul><li>Thread Safe <strong>Cons</strong>:</li><li>Instance is created when the Config class is first initialized</li><li>if the class gets touched for some other reason before you need the instance.</li></ul><p><strong>How does it work?</strong></p><ul><li>JVM loads the class along with static memebers on class Load</li><li>Static key word enables to have only one copy of the member</li><li>Final keyword restricts changing value to the member</li></ul><p>Thread safe is the ability of a piece of code, class, method to be safely used in a multi threaded applications at the same time. This prevents data corruption.</p><p><strong>2. Lazy initialization</strong></p><pre>public class Config{<br>        private static Config instance;<br>        private Config(){}<br>        public static Config getInstance(){<br>            if(instance == null){<br>                instance =  new Config();<br>            }<br>            return instance;<br>        }<br>    }</pre><p><strong>Cons</strong>:</p><ul><li>This is broken under concurrency — non thread safe.</li></ul><p><strong>How does it work?</strong>:</p><ul><li>If two threads try to get the instance, both of them will create a new instance.</li></ul><p><strong>3. Synchronized method</strong></p><pre>public class Config{<br>        private static Config instance;<br>        private Config(){}<br>        public static synchronized Config getInstance(){<br>            if(instance == null){<br>                instance = new Config();<br>            }<br>            return instance;<br>        }<br>    }</pre><p><strong>Pros:</strong></p><ul><li>Thread safe due to synchronised keyword.</li><li>Each thread wait for curent thread execution</li></ul><p><strong>Cons:</strong></p><ul><li>A thread have to wait untill the current thread completes it’s operation even though an instance exists for the same class</li><li>Adds up locking costs on application, results in slow performance at scale</li></ul><p><strong>4. Double checked locking:</strong></p><pre>public class Config{<br>        private static volatile Config instance;<br>        private Config(){}<br>        public static Config getInstance(){<br>            if(instance == null){<br>                synchronized(Config.class){<br>                    if(instance == null){<br>                        instance = new Config();<br>                    }<br>                }<br>            }<br>            return instance;<br>        }<br>    }</pre><p><em>volatile keyword prevents a thread from seeing partially constructed object</em></p><p><strong>Hows does it works?</strong></p><ul><li>The first check avoids locking, if the instance exists</li><li>The synchronized block does the locking, and the second check prevents duplicate creation.</li><li>Without volatile, the risk is another thread seeing a partially constructed object because of instruction reordering</li></ul><p><strong>Pros:</strong></p><ul><li>Prevents duplicate object creation, thread safe</li></ul><p><strong>5. Static Holder Idiom — Lazy</strong></p><pre>public class Config{<br>    private Config(){}<br>    public static Config getInstance(){<br>        return Holder.instance;<br>    }<br>    private static class Holder{<br>        private static final Config instance = new Config();<br>    }<br>}</pre><p><strong>Pros:</strong></p><ul><li>Thread safe</li><li>Lazy load</li></ul><p><strong>How does it work?:</strong></p><ul><li>The holder class is not loaded until the getinstane method is call</li><li>JVM guarantees thread safety with static class execution</li></ul><p><strong>6.Enum Singleton</strong></p><pre>public enum Config{<br>    INSTANCE;<br>    private final Properties prop;<br>    Config(){<br>        props = new Properties();<br>    }<br>    public String get(String key){ return prop.getProperty(key); }<br>}</pre><p><strong>Pros:</strong></p><ul><li>Thread safe, serialization safe immune to reflection attacks.</li></ul><p><strong>Cons:</strong></p><ul><li>Can’t extend another class</li><li>The enum is initialized on first use of the class</li></ul><p><strong>How does it work?</strong></p><ul><li>Instance; is shorthand for: public static final Config Instance = new Config();</li><li>To use it we can call String value = Config.Instance.get(&quot;db.url&quot;);</li></ul><h3>How to break a singleton?</h3><ul><li><strong>Reflection</strong> : setAccessible(true) on a private constructor can create a second instance. if the instance already exists, We can throw an error in ths constructor.</li><li><strong>Serialization</strong> : Deserializing creates a new object. We can fix it by implementing readResolve() to return existing instance.</li><li>A serializable singleton breaks when you deserialize it, because Java creates a new object from the byte stream without calling your constructor.</li></ul><pre>public class Config implements Serializable {<br>    private static final Config INSTANCE = new Config();<br>private Config() {}public static Config getInstance() <br>{ <br>return INSTANCE; <br>}<br>}<br></pre><pre>Config a = Config.getInstance();</pre><pre>ByteArrayOutputStream bos = new ByteArrayOutputStream();<br>new ObjectOutputStream(bos).writeObject(a);</pre><pre>Config b = (Config) new ObjectInputStream(<br>    new ByteArrayInputStream(bos.toByteArray())).readObject();</pre><pre>System.out.println(a == b);   // false -&gt; two instances, singleton broken</pre><ul><li><strong>Below is the fix</strong></li></ul><pre>public class Config implements Serializable {<br>private static final Config INSTANCE = new Config();</pre><pre>private Config() {}</pre><pre>public static Config getInstance() { return INSTANCE; }</pre><pre>private Object readResolve() {<br>    return INSTANCE;<br>}<br>}</pre><p><strong>How it works</strong></p><ul><li>readObject() deserializes the bytes and builds a new Config object.</li><li>Before returning it, Java checks whether the class defines a method named readResolve() with exactly this signature.</li><li>If it does, Java calls it and returns its result instead of the newly built object.</li><li>The freshly created object is discarded and becomes garbage.</li></ul><p><strong>Signature rules</strong></p><ul><li>Name must be readResolve, with no parameters.</li><li>Return type must be Object.</li><li>It can be private, protected, or public. private works for this class only; subclasses won’t inherit it, while protected or public would be inherited.</li><li><strong>Cloning</strong>: If the class implements Cloneable, clone() can produce a copy. Override it to throw an exception or return the same instance.</li><li><strong>Multiple class loaders:</strong> Each class loader can have its own “singleton,” so the guarantee is per class loader, not per JVM.</li></ul><h3>Criticisms and trade-offs</h3><ul><li><strong>Hidden dependencies:</strong> Code calling Config.getInstance() hides what it depends on, unlike constructor injection.</li><li><strong>Hard to test:</strong> Global state persists between tests and is difficult to mock or replace.</li><li><strong>Violates single responsibility:</strong> The class manages its own lifecycle as well as its business logic.</li><li><strong>Concurrency risk:</strong> Mutable shared state inside a singleton needs its own thread-safety handling. The pattern only guarantees one instance, not safe use of it.</li></ul><p>In modern codebases (Spring, for example), a “singleton” is usually a container-managed scope: the framework creates one instance and injects it where needed. You get the single-instance behavior without the static access point, which avoids most of the testing and coupling problems above.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d854bd648d77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Kafka locally in minutes]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@don-prudhvi/implementing-kafka-locally-in-minutes-965912029048?source=rss-ad4f6aeca62c------2"><img src="https://cdn-images-1.medium.com/max/1273/0*P_LaZtsz6yKEKEqC" width="1273"></a></p><p class="medium-feed-snippet">This is a step-by-step guide to installing, configuring, and running Apache Kafka in KRaft mode (without ZooKeeper), along with key&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@don-prudhvi/implementing-kafka-locally-in-minutes-965912029048?source=rss-ad4f6aeca62c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@don-prudhvi/implementing-kafka-locally-in-minutes-965912029048?source=rss-ad4f6aeca62c------2</link>
            <guid isPermaLink="false">https://medium.com/p/965912029048</guid>
            <dc:creator><![CDATA[Prudhvi Donempudi]]></dc:creator>
            <pubDate>Mon, 26 Oct 2026 05:57:28 GMT</pubDate>
            <atom:updated>2026-10-26T05:57:28.222Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Classpath is empty. Please build the project first e.g. by running ‘./gradlew jar -PscalaVersion=]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">While setting up a Kafka implementation locally, you could have come across the error &#x201C;Classpath is empty. Please build the project first&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/@don-prudhvi/classpath-is-empty-please-build-the-project-first-e-g-by-running-gradlew-jar-pscalaversion-4bd13060b193?source=rss-ad4f6aeca62c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@don-prudhvi/classpath-is-empty-please-build-the-project-first-e-g-by-running-gradlew-jar-pscalaversion-4bd13060b193?source=rss-ad4f6aeca62c------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bd13060b193</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[apache-kafka-tutorial]]></category>
            <dc:creator><![CDATA[Prudhvi Donempudi]]></dc:creator>
            <pubDate>Sat, 24 Oct 2026 16:56:36 GMT</pubDate>
            <atom:updated>2026-10-24T16:56:36.060Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[“Unable to map the subject to a Salesforce user” Error while using Salesforce SSO with Standard…]]></title>
            <link>https://medium.com/@don-prudhvi/unable-to-map-the-subject-to-a-salesforce-user-error-while-using-salesforce-sso-with-standard-dac3fe9c830b?source=rss-ad4f6aeca62c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dac3fe9c830b</guid>
            <dc:creator><![CDATA[Prudhvi Donempudi]]></dc:creator>
            <pubDate>Mon, 17 Mar 2025 06:51:29 GMT</pubDate>
            <atom:updated>2025-03-17T06:51:29.369Z</atom:updated>
            <content:encoded><![CDATA[<h3>“Unable to map the subject to a Salesforce user” Error while using Salesforce SSO with Standard User Provisioning.</h3><p>One of the most common error while configuring single sign-on with salesforce as a service provider using standard user provisioning also called Just-in-time User Provisioning is the <strong>Unable to map the subject to a Salesforce user error</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0yRYw2nFPFrtv9sveLHqBQ.png" /></figure><p>While this appears to be very straight forward on the foreground, in the background it is not. The platform says that is unable to map the user to an existing user. While in the background we really don’t know if the user was created in the first place. Follow this article if you are getting the same error while configuring JIT for new users.</p><h3><strong>What needs to be checked ?</strong></h3><ul><li>Make sure that you are aware of the attributes that are required from identity provider in the SAML response while using JIT.</li><li>Email, LastName,ProfileId and Username fields are must for a user to be created on salesforce while using JIT.</li><li>Every field for user creation must be shared in the SAML assertion with the SAML attribute name starting with <strong>User.</strong> prefix. <br>For example: If you are sending the email from IDP, in order to let salesforce understand that this field is used for user creation then there must be a SAML attribute in the SAML response that should look like below. <br>&lt;saml:Attribute <br> Name=&quot;User.Email&quot; <br> NameFormat=&quot;urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified&quot;&gt;<br> &lt;saml:AttributeValue xsi:type=&quot;xs:anyType&quot;&gt;abcd@test.com&lt;/saml:AttributeValue&gt;<br>&lt;/saml:Attribute&gt;</li><li>Since most of the IDPs does not contain the OOTB fields that are required by Salesforce for JIT, we must create the custom attributes/claims on the IDP side.</li><li>Please see the below image on how the custom attributes/claims are set on Azure.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8QWAsG4KRAzBwzSzVFQyA.png" /></figure><ul><li>So, In Azure I have a field named mail on the active directory, and I’m mapping that to the <strong>Email</strong> field on the salesforce using the attribute name <strong>User.Email. Same goes for remaining fields.</strong></li><li>If you are able to send the required fields, Salesforce platform is expected to create a new user or log in the existing user using the SAML subject’s unique identifier.</li></ul><p><strong>References : <br></strong><a href="https://help.salesforce.com/s/articleView?id=xcloud.sso_jit_requirements.htm&amp;type=5">Just-in-Time SAML Assertion Fields for Salesforce</a></p><p><a href="https://help.salesforce.com/s/articleView?id=xcloud.sso_saml_assertion_examples.htm&amp;type=5">Example SAML Assertions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dac3fe9c830b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>