<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Eyal Katz</title>
    <description>The latest articles on Forem by Eyal Katz (@eyalk100).</description>
    <link>https://forem.com/eyalk100</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F276862%2Facb58d4e-424e-42a1-a67f-1ba215c31761.JPG</url>
      <title>Forem: Eyal Katz</title>
      <link>https://forem.com/eyalk100</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/eyalk100"/>
    <language>en</language>
    <item>
      <title>Using the Redis Command-Line Correctly</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Wed, 07 Jul 2021 08:21:50 +0000</pubDate>
      <link>https://forem.com/eyalk100/using-the-redis-command-line-correctly-hk5</link>
      <guid>https://forem.com/eyalk100/using-the-redis-command-line-correctly-hk5</guid>
      <description>&lt;p&gt;Zora Cooper is a web dev and technical writer who I have had worked with on a number of projects. She wrote a perfect guide on how to properly &lt;a href="https://lightrun.com/debugging/using-the-redis-command-line/"&gt;use the Redis command-line&lt;/a&gt; including examples and a step by step tutorial. &lt;/p&gt;

&lt;p&gt;Redis is an open-source in-memory data store. You can use Redis as a database, message broker, or cache. It also supports &lt;a href="https://redis.io/commands/eval"&gt;Lua script evaluation&lt;/a&gt; so you can build automation scripts or custom operations on top of your key-value Redis store.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Typically, developers use language-specific &lt;a href="https://redis.io/clients"&gt;client libraries&lt;/a&gt; when building apps with Redis. These clients abstract Redis’ command-line interface (CLI), making it easier to work with but more work to set up&lt;/strong&gt;. Client libraries are great when you’re already using Redis in a project but not as useful for trying things out or &lt;a href="https://lightrun.com/debugging/testing-in-production-recommended-tools/"&gt;debugging a production&lt;/a&gt; data store. For that, the Redis CLI is your best bet.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Redis CLI is a great choice for prototyping before implementation, troubleshooting, and experimentation because it’s faster to get started with and more flexible&lt;/strong&gt;. It provides tab completion, a history of your commands, and all the functionality you need to read, write, update, delete, or debug data in Redis.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IBg9GXuy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynsm63o8yjd7i5h1sa36.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IBg9GXuy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ynsm63o8yjd7i5h1sa36.png" alt="redis cli"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this article, you’ll learn everything you need to know about using the Redis command-line correctly:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://lightrun.com/debugging/using-the-redis-command-line/#connecting-to-redis"&gt;How to use the CLI to connect to a Redis server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lightrun.com/debugging/using-the-redis-command-line/#crud"&gt;How to add and manipulate data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lightrun.com/debugging/using-the-redis-command-line/#lua"&gt;Run Lua scripts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://lightrun.com/debugging/using-the-redis-command-line/#debugging"&gt;Perform debugging operations&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Along the way, I’ll offer some context to help you understand when you might use each of these features.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting to Redis
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Before you start using the Redis command-line, make sure you have it installed&lt;/strong&gt;. You can find installation instructions &lt;a href="https://redis.io/download"&gt;here&lt;/a&gt;, and once complete, you can check if your installation was successful by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli --help
redis-cli 6.2.3
Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Redis connects to a server at &lt;strong&gt;127.0.0.1&lt;/strong&gt; on port &lt;strong&gt;6379&lt;/strong&gt; by default. You can change the hostname using the -h flag and the port using the &lt;strong&gt;-p&lt;/strong&gt; flag. To connect to a Redis server at &lt;strong&gt;example.com:3001&lt;/strong&gt;, run the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli -h example.com -p 3001
example.com:3001&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a password and username have been set for the server, you can provide them with the &lt;strong&gt;-u&lt;/strong&gt; flag for username and &lt;strong&gt;-a&lt;/strong&gt; for password. Using these flags is not recommended as anyone who &lt;a href="https://spectralops.io/blog/the-beginners-guide-to-preventing-data-breaches-in-your-code/"&gt;retrieves your bash history&lt;/a&gt; will be able to see your password, so it’s usually better to use the &lt;strong&gt;AUTH&lt;/strong&gt; command in interactive mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli
AUTH &amp;lt;username&amp;gt; &amp;lt;password&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also set the password &lt;a href="https://stackoverflow.com/a/64372000"&gt;using the &lt;code&gt;REDISCLI_AUTH&lt;/code&gt; environment variable&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Selecting a Redis Database
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A Redis server has 16 databases by default&lt;/strong&gt;. The databases are zero-indexed, with the first database being &lt;strong&gt;0&lt;/strong&gt;. You can check the actual number by running &lt;code&gt;redis-cli config get databases&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In interactive mode, the database number is displayed in the prompt within square braces. For example, &lt;code&gt;127.0.0.1:6379[13]&lt;/code&gt; shows that the 13th database is in use.&lt;/p&gt;

&lt;p&gt;To select a database when connecting, pass its database number with the &lt;strong&gt;-n&lt;/strong&gt; flag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli -n 1
127.0.0.1:6379[1]&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’d like to combine all of the above commands, use the &lt;strong&gt;-u&lt;/strong&gt; flag to specify a complete server URI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli -u redis://&amp;lt;username&amp;gt;:&amp;lt;password&amp;gt;@&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;database-number&amp;gt;
$ redis-cli -u redis://&amp;lt;password&amp;gt;@&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;database-number&amp;gt;
$ redis-cli -u redis://&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/&amp;lt;database-number&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CRUD Operations Using the Redis Command-Line
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The commands used for CRUD operations differ depending on the type of data being handled&lt;/strong&gt;, but first, you have to understand a bit about how Redis stores this data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Redis keys are distinct identifiers associated with a value&lt;/strong&gt;. They are used to perform operations on values (deletes, reads, and updates, for example). The values we will look at include strings, lists, sets, sorted sets, and hashes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keys and string values can take on the form of numbers, characters, or files.&lt;/li&gt;
&lt;li&gt;A list is a string collection sorted by the order the elements were inserted.&lt;/li&gt;
&lt;li&gt;A set is an unsorted list where elements must be unique.&lt;/li&gt;
&lt;li&gt;A sorted set is just a set where each element is assigned a score, and the set is sorted by score.&lt;/li&gt;
&lt;li&gt;Hashes are maps containing field-value string pairs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Redis also supports streams, &lt;a href="https://thoughtbot.com/blog/hyperloglogs-in-redis"&gt;hyperloglogs&lt;/a&gt;, and bit arrays, which you can read more about in the &lt;a href="https://redis.io/topics/data-types-intro"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding Data to Redis
&lt;/h3&gt;

&lt;p&gt;Keys with string values are created with the &lt;strong&gt;SET&lt;/strong&gt; command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli set cat-count 10
OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To create a key with a list value and add elements to it, use either &lt;strong&gt;RPUSH&lt;/strong&gt; or &lt;strong&gt;LPUSH&lt;/strong&gt; commands. &lt;strong&gt;LPUSH&lt;/strong&gt; adds elements to the beginning of a list, and &lt;strong&gt;RPUSH&lt;/strong&gt; adds them to the end.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli rpush cat-breeds persian ragdoll bengal
(integer) 3
$ redis-cli lpush hairless-cats sphynx
(integer) 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;SADD&lt;/strong&gt; (short for “set-add”) will create a key with a set value and add members to it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli sadd cities london zurich berlin 
(integer) 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For keys with sorted set values, use the &lt;strong&gt;ZADD&lt;/strong&gt; command.&lt;/p&gt;

&lt;p&gt;$ redis-cli zadd fruits 52 apple 47 orange&lt;br&gt;
(integer) 2&lt;br&gt;
&lt;strong&gt;HSET&lt;/strong&gt; and &lt;strong&gt;HMSET&lt;/strong&gt; create keys with hash values and add fields to them. &lt;strong&gt;HMSET&lt;/strong&gt; sets multiple hash fields while &lt;strong&gt;HSET&lt;/strong&gt; sets just one at a time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli hset cat1 breed norwegian
(integer) 1
$ redis-cli hmset cat2 breed bobtail coat long
OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Updating Data Using the Redis CLI
&lt;/h3&gt;

&lt;p&gt;Updating string values in a Redis store can be done using one of several commands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;SET&lt;/strong&gt; command can update an existing key with a string value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;APPEND&lt;/strong&gt; appends a value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DECR&lt;/strong&gt; decrements a value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GETSET&lt;/strong&gt; sets a new value and returns the old value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;INCR&lt;/strong&gt; increments a value&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SETNX&lt;/strong&gt; sets a value if it exists
Other update commands for keys with string values can be found using the &lt;strong&gt;help @string&lt;/strong&gt; command in Redis’s interactive mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are also several commands for updating a list value:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;LPUSH&lt;/strong&gt; and &lt;strong&gt;RPUSH&lt;/strong&gt; (which I mentioned above) can be used to add new values to a list&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;RPUSHX&lt;/strong&gt; appends an element to the end of a list if the key exists&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LPUSHX&lt;/strong&gt; adds an element to the beginning of a list if the key exists&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LINSERT&lt;/strong&gt; inserts a new element between existing elements in a list&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Similarly, you can use &lt;strong&gt;help @list&lt;/strong&gt; in interactive mode to see all the Redis commands that can manage list values.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding and updating data manually in Redis is useful when you want to replicate production conditions in a test environment&lt;/strong&gt;. For example, if you have a specific list that is causing errors in production, you could add it to your local environment and trace the error through your code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reading Data from Redis
&lt;/h3&gt;

&lt;p&gt;Reading data from Redis is a good way to figure out if specific values are causing application errors. To retrieve a key with a string value, use the GET command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli get cat-count
"10"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If a value does not exist for this key, &lt;strong&gt;GET&lt;/strong&gt; replies with a &lt;strong&gt;nil&lt;/strong&gt; value.&lt;/p&gt;

&lt;p&gt;Since &lt;strong&gt;GET&lt;/strong&gt; only works with string values, you need the &lt;strong&gt;LRANGE&lt;/strong&gt; command to get list values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli lrange cat-breeds 0 -1
1) "persian"
2) "ragdoll"
3) "bengal"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“0” in the example above specifies the start index of the list and “-1” the end. This command can also be helpful when attempting to fetch a subset of elements from a large list.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;SMEMBERS&lt;/strong&gt; command will fetch all the members in a set, and the &lt;strong&gt;ZRANGE&lt;/strong&gt; command returns members between a start and end index in a sorted set.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli zrange fruits 0 -1
1) "orange"
2) "apple"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, &lt;strong&gt;HGETALL&lt;/strong&gt;, &lt;strong&gt;HGET&lt;/strong&gt;, and &lt;strong&gt;HMGET&lt;/strong&gt; will retrieve hash values. &lt;strong&gt;HGETALL&lt;/strong&gt; will return all the field-value pairs in a hash if you would like to see it entirely. If you would like to just see one field-value pair, you would use &lt;strong&gt;HGET&lt;/strong&gt;. &lt;strong&gt;HMGET&lt;/strong&gt; would be useful if you’d like to view multiple specific field-value pairs of a hash.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli hgetall cat1
1) "breed"
2) "norwegian"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Reading all these values in the command line might be good for small lists or sets, but if you’re dealing with thousands of rows, this won’t work. Using the --csv flag, you can get CSV output that can be opened in a text editor or spreadsheet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deleting Data
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Another common operation in Redis is deleting data&lt;/strong&gt;. You might use this to delete problematic caches, clear up a backlogged message queue, or reset your local Redis data.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;DEL&lt;/strong&gt; command will delete one or more values by their keys. If you try to delete a non-existent key, it is ignored, and the server will reply with the number of successfully deleted keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli del cats
(integer) 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you realize you made a mistake, you can restore a key using the &lt;strong&gt;RESTORE&lt;/strong&gt; command.&lt;/p&gt;

&lt;p&gt;There are other type-specific delete commands to remove elements, members, or fields from a key:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To remove specific elements from a list instead of deleting the whole key, you would use &lt;strong&gt;LREM&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;To remove a subset of elements in a list, you could use &lt;strong&gt;LTRIM&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;For sets, &lt;strong&gt;SREM&lt;/strong&gt; would remove one or more members&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SPOP&lt;/strong&gt; would be useful for removing a member from a set and returning it as output&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ZREM&lt;/strong&gt; will remove a single or multiple members from a sorted set&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HDEL&lt;/strong&gt; would help delete a field from a hash
For a full list use &lt;strong&gt;help @&lt;/strong&gt; in interactive mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bulk Data Insertion Using the Redis CLI
&lt;/h2&gt;

&lt;p&gt;If you want to migrate data from one Redis instance to another or upload a large sample data set, you could write a bash script to run &lt;strong&gt;SET&lt;/strong&gt; repeatedly, or you can add data in bulk using the &lt;strong&gt;--pipe flag&lt;/strong&gt;. This flag takes the path of the file containing all your Redis operations.&lt;/p&gt;

&lt;p&gt;Since different data types are created using different commands, you have to specify the command when inserting data, even in bulk. For example, consider the &lt;strong&gt;insert-data.txt&lt;/strong&gt; file below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SET counter 1
SET tracker 2
LPUSH cities Paris Berlin
LPUSH countries France Germany
RPUSH fruits apple orange 
RPUSH vegetables carrot cucumber
SADD tiers s a b c d
ZADD scores 52 jane 47 paul
HMSET user01 name Jane age 23
HMSET user02 name Reggie age 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can insert the data above by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cat insert-data.txt | redis-cli --pipe
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s slightly arduous to get all these commands right, but it will be faster than connecting to Redis multiple times to loop over a shell command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running Lua Scripts with Redis CLI
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.lua.org/"&gt;Lua&lt;/a&gt; is a lightweight scripting language that you can use to interact with Redis servers&lt;/strong&gt;. If you’d like more flexibility when using Redis and take advantage of features such as comments, variables, conditional statements, functions, and loops, Lua scripts can be pretty helpful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KWfn4JDL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5hxei6eajcqz6t7vyoj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KWfn4JDL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5hxei6eajcqz6t7vyoj.jpeg" alt="redis lua"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lua scripts are evaluated when the &lt;strong&gt;--eval&lt;/strong&gt; flag is used. This flag takes a path to a Lua file, but you can also provide keys or other arguments to the script.&lt;/p&gt;

&lt;p&gt;For example, this &lt;strong&gt;add-counters.lua&lt;/strong&gt; script adds five counters to the Redis database:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i=1, 5 do
    redis.call('set', 'counter' .. i, i)
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To run it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli --eval add-counters.lua
(nil)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keys are made available within the script in the &lt;strong&gt;KEYS&lt;/strong&gt; table and arguments in the &lt;strong&gt;ARGV&lt;/strong&gt; table. Here is an example of how you would use them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for i=1, #KEYS do
    redis.call('hmset', 'user0' .. i, 'name', KEYS[i], 'age', ARGV[i])
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The keys and arguments are passed to the script as a comma-separated list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli --eval add-users.lua Jane , 23 , John , 20 , Paula , 30
(nil)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Redis provides a Lua debugger that’s especially useful for debugging complicated Lua scripts. To use it, pass the &lt;strong&gt;--ldb flag&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli --ldb --eval add-users.lua Jane , 23 , John , 20 , Paula , 30
Lua debugging session started, please use:
quit    -- End the session.
restart -- Restart the script in debug mode again.
help    -- Show Lua script debugging commands.
* Stopped at 1, stop reason = step over
-&amp;gt; 1   for i=1, #KEYS do
lua debugger&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The debugger will save you a lot of time as you’re tweaking your Lua scripts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interactive vs Command-Line Arguments
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The Redis CLI can be called using command-line arguments or by starting an interactive shell.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you specify command-line arguments using &lt;strong&gt;redis-cli&lt;/strong&gt;, the Redis client sends them to the server, prints the results, and then exits. You will have to run &lt;strong&gt;redis-cli&lt;/strong&gt; again with new commands to issue more. That’s how all the examples in this tutorial have worked so far.&lt;/p&gt;

&lt;p&gt;In interactive mode, after a command is processed by the server, results are printed, and you can continue issuing further commands in the prompt. You do not need to keep typing &lt;strong&gt;redis-cli&lt;/strong&gt;. The CLI can be run in interactive mode by executing &lt;strong&gt;redis-cli&lt;/strong&gt; without any arguments:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli
127.0.0.1:6379[2]&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In interactive mode, the Redis CLI includes command completion, hints, and better help information, so you might spend a lot of time here when you’re debugging Redis.&lt;/p&gt;

&lt;h2&gt;
  
  
  Seeing a Summary of Redis Storage Contents
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Some issues in Redis arise when your server is running a different version in testing than in production&lt;/strong&gt;. The &lt;strong&gt;INFO&lt;/strong&gt; command provides information and statistics about the Redis server, including version, operating system, uptime, clients, memory consumption, commands processed, and keyspace information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli info
# Server
redis_version:6.2.3
redis_git_sha1:00000000
redis_git_dirty:0
redis_mode:standalone
os:Linux 5.8.0-53-generic x86_64
arch_bits:64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can check the number of keys in a database using the &lt;strong&gt;DBSIZE&lt;/strong&gt; command. The &lt;strong&gt;-n&lt;/strong&gt; flag specifies the database you’d like to check. This can be especially useful when debugging and tracking keys added to your database.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli -n 0 dbsize
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For real-time information and stats about the server, use the &lt;strong&gt;--stat&lt;/strong&gt; flag. Every second it prints out the number of clients connected, requests, connections, and keys.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ redis-cli --stat
------- data ------ --------------------- load -------------------- - child -
keys       mem      clients blocked requests            connections          
1          855.56K  1       0       122 (+0)            36          
1          855.56K  1       0       123 (+1)            36          
1          855.56K  1       0       124 (+1)            36          
1          855.56K  1       0       125 (+1)            36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can come in handy when you need to find out the number of clients connected to a server, how requests are being processed, or how many connections have been made recently.&lt;/p&gt;

&lt;h3&gt;
  
  
  More Redis Command-Line Features
&lt;/h3&gt;

&lt;p&gt;While I offered an overview of some of the most important features Redis’s command-line interface has to offer, there are many other features you might want to learn.&lt;/p&gt;

&lt;p&gt;For example, you can use the &lt;strong&gt;MONITOR&lt;/strong&gt; command to view all server requests in real-time. Redis also provides support for &lt;a href="https://redis.io/topics/pubsub"&gt;pub/sub messaging&lt;/a&gt;, which you can access via the command-line.&lt;/p&gt;

&lt;p&gt;Knowing how to use the Redis CLI enables you to take full advantage of its powerful features without the setup time required when using client libraries in your code. The Redis CLI is especially helpful for learning how Redis works, solving server issues, testing commands quickly, and Redis &lt;a href="https://lightrun.com/best-practices/continuous-monitoring-what-is-it-and-how-is-it-impacting-devops-today/"&gt;server monitoring&lt;/a&gt;, so it’s worth learning how to use it correctly.&lt;/p&gt;

</description>
      <category>redis</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to Debug Race Conditions Between Threads in Java</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Mon, 28 Jun 2021 07:11:24 +0000</pubDate>
      <link>https://forem.com/eyalk100/how-to-debug-race-conditions-between-threads-in-java-13lm</link>
      <guid>https://forem.com/eyalk100/how-to-debug-race-conditions-between-threads-in-java-13lm</guid>
      <description>&lt;p&gt;Derrick Wadek is a gifted full-stack Android engineer with a wealth of experience and wisdom to share. He wrote this excellent &lt;a href="https://lightrun.com/debugging/how-to-debug-race-conditions-between-threads-in-java/" rel="noopener noreferrer"&gt;guide on Java debugging&lt;/a&gt; to remedy complex race conditions.&lt;/p&gt;

&lt;p&gt;How many days off have been marred by debugging race conditions and deadlocks in complex multithreaded, Java code? You’ve probably vowed, Never again and embarked on a quest to always catch race condition errors early by writing tests and debugging.&lt;/p&gt;

&lt;p&gt;Multithreaded applications are a great way to improve performance, but they also make routine tasks like debugging a little more complicated. In this tutorial, you’ll learn an overview of what race conditions are, what multithreaded Java code is used for, and finally how to debug race conditions in Java using a few different methods.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Multithreading?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Multithreading is the ability for a program to run two or more threads concurrently, where each thread can handle a different task at the same time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;More specifically, a program is divided into two or more sub programs, which can be implemented at the same time in parallel:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static void computeCounter(){
       Counter counter = new Counter() ;
       Thread threadOne = new Thread(getRunnable(counter , "Thread one count is: "));
       Thread threadTwo = new Thread(getRunnable(counter , "Thread two count is: "));
       threadOne.start();
       threadTwo.start();
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Benefits of a Multithreaded Application
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;It &lt;strong&gt;enables you to do multiple things&lt;/strong&gt; at a time.&lt;/li&gt;
&lt;li&gt;You can &lt;strong&gt;divide a long process into threads&lt;/strong&gt; and &lt;strong&gt;execute them in parallel&lt;/strong&gt;, which will eventually increase the speed of program execution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Simultaneous access&lt;/strong&gt; to multiple applications.&lt;/li&gt;
&lt;li&gt;It &lt;strong&gt;improves performance by optimizing available resources&lt;/strong&gt;, especially when your PC has multiple CPUs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By default, all your program code runs on the main thread, which means if you have a 4-core CPU, &lt;strong&gt;only one core will be used to execute your code&lt;/strong&gt;. This means that &lt;strong&gt;code will be executed one after the other, and only until the previous program is finished will the next be executed&lt;/strong&gt;. On the other hand, if you use multithreading with three threads running concurrently, each thread will occupy separate cores and the program will be executed in parallel, reducing the amount of time to execute your program.&lt;/p&gt;

&lt;p&gt;The following is a simple program that computes flight charges for each flight category. The category will be checked and a charge set on each.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class FlightCategories {

    static final int FIRST_CLASS = 1;
    static final int BUSINESS_CLASS = 2;
    static final int ECONOMY_CLASS = 3;
    public static void main(String[] args){
        System.out.println("===== Application Running =====");
        try {
            FlightCharges firstClass = new FlightCharges(FIRST_CLASS);
            firstClass.computeFlightCharges();
            FlightCharges businessClass = new FlightCharges(BUSINESS_CLASS);
            businessClass.computeFlightCharges();
            FlightCharges economyClass = new FlightCharges(ECONOMY_CLASS);
            economyClass.computeFlightCharges();
            System.out.println("First class charges are "+firstClass.getCharges());
            System.out.println("Business class charges are "+businessClass.getCharges());
            System.out.println("Economy class charges are "+economyClass.getCharges());
        } catch (Exception e){
            System.out.println("Encountered error "+e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class FlightCharges {
    private int category = 0;
    private double charges = 0;
    public FlightCharges(int category) {
        this.category = category;
    }
    public double getCharges() {
        return charges;
    }
    private void setCharges(double charges) {
        this.charges = charges;
    }
    public void computeFlightCharges(){
        try {
            switch (category){
                case 1:
                    setCharges(500.0);
                    break;
                case 2:
                    setCharges(250.0);
                    break;
                case 3:
                    setCharges(150.0);
                    break;
            }
        } catch (Exception e){
            System.out.println("Exception "+e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Observe the time it took to execute it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fln0l5nchnfn4j90ba9m1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fln0l5nchnfn4j90ba9m1.png" alt="Build Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It took roughly 443 ms to execute this simple program. Now repeat the same process using multithreading as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class FlightCategoriesMultithreading {
    static final int ECONOMY_CLASS = 3;
    static final int BUSINESS_CLASS = 2;
    static final int FIRST_CLASS = 1;
    public static void main(String[] args){
        System.out.println("===== Application Running =====");
        try {
            FlightChargesMultithreading firstClass = new FlightChargesMultithreading(FIRST_CLASS);
            Thread t1 = new Thread(firstClass);
            t1.start();
            FlightChargesMultithreading businessClass = new FlightChargesMultithreading(BUSINESS_CLASS);
            Thread t2 = new Thread(businessClass);
            t2.start();
            FlightChargesMultithreading economyClass = new FlightChargesMultithreading(ECONOMY_CLASS);
            Thread t3 = new Thread(economyClass);
            t3.start();
            System.out.println("First class charges are "+firstClass.getCharges());
            System.out.println("Business class charges are "+businessClass.getCharges());
            System.out.println("Economy class charges are "+economyClass.getCharges());
        } catch (Exception e){
            System.out.println("Encountered error "+e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class FlightChargesMultithreading implements Runnable{
    private int category = 0;
    private double charges = 0;
    public FlightChargesMultithreading(int category) {
        this.category = category;
    }
    public double getCharges() {
        return charges;
    }
    private void setCharges(double charges) {
        this.charges = charges;
    }
    @Override
    public void run() {
        try {
            switch (category){
                case 1:
                    setCharges(500.0);
                    break;
                case 2:
                    setCharges(250.0);
                    break;
                case 3:
                    setCharges(150.0);
                    break;
            }
        } catch (Exception e){
            System.out.println("Exception "+e.getMessage());
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dkr7px8w2o13rnc1orv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4dkr7px8w2o13rnc1orv.png" alt="Build Output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It only took 150 ms to execute the same program! For a simple program like this, this might not seem much, but the more complex a program gets, multithreading becomes crucial to performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Challenges of Multithreaded Applications
&lt;/h3&gt;

&lt;p&gt;Concurrency greatly improves performance but at the detriment of &lt;a href="https://lightrun.com/debugging/debugging-microservices-in-production-an-overview/" rel="noopener noreferrer"&gt;debugging&lt;/a&gt;. Why? Because &lt;strong&gt;it’s easy to catch errors in a single thread but notoriously difficult to replicate bugs when tracking multiple threads.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Take, for example, the previous code that simply computed flight charges depending on flight categories. When logging the code, it will take some time to check the category of flight and set charges to it. The extra time could often fix the issue—most multithreading bugs are sensitive to the timing of events in your application, so &lt;strong&gt;running your code under a debugger changes the timing&lt;/strong&gt;. Your debugger may fail to replicate the bug.&lt;/p&gt;

&lt;p&gt;The bottom line is that &lt;strong&gt;multithreading is an important and useful aspect of development, but comes with its fair share of challenges&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Race Conditions?
&lt;/h2&gt;

&lt;p&gt;Detecting race conditions is particularly difficult. &lt;strong&gt;A race condition is a behavior that’s dependent on a “race” between two threads as to which one will be executed first. Two or more threads access the same variable or data in a way where the final result stored in the variable depends on how thread access to the variable is scheduled.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thread (t1) in the &lt;code&gt;FlightCategoriesMultithreading.java&lt;/code&gt; example above will certainly finish first in most ideal situations and this will be your expected result. The problem occurs in rare cases when one of the remaining threads (t2 or t3) finishes first. In a more complex multithreaded application running hundreds of threads, this is a potential debugging nightmare and replicating these bugs would be hard!&lt;/p&gt;

&lt;p&gt;Essentially, the two threads read and write the same variables or data concurrently instead of consecutively, using either of these patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check, then act.&lt;/li&gt;
&lt;li&gt;Read, modify, write, where the modified value depends on the previously read value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because the thread access to the variables or data is not atomic, it can cause some issues. Here’s a diagram to illustrate this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbrz1kuhjq0cs6qulmd4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flbrz1kuhjq0cs6qulmd4.png" alt="CPU Threads Diagram 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What Should Happen
&lt;/h3&gt;

&lt;p&gt;First the CPU 1 thread will read the value of the counter class into a local CPU register where the thread is running, increment the value by 1, and write that value back to main memory. When the second thread (CPU 2) reads the count, it reads the value 1 incremented by 1 and then writes the value 2 back to main memory.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Actually Happens
&lt;/h3&gt;

&lt;p&gt;Instead of sequential access as shown in the diagram above, the threads use interleaved access. Thread 1 reads the value 0 from the counter into a CPU register, and at the exact same time, thread 2 reads the value 0 from the counter into a local CPU register for thread 2.&lt;/p&gt;

&lt;p&gt;This causes both threads to increment the value that they have stored in their own CPU and write it back. So thread 1 will increment from 0 to 1 and write back 1, but thread 2 will also increment from 0 to 1 and write back 1. So, we expect the counter to read 2, but because of the interleaved access, it reads 1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl9yerm4wtri3a00uav8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzl9yerm4wtri3a00uav8.png" alt="CPU Threads Diagram 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As an example, the following code snippet simply iterates over the counter a million times and prints out the value of both threads to the console:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class RaceConditionExample {
    private static Runnable getRunnable(Counter counter , String output) {
        return () -&amp;gt; {
            for (int i = 0 ; i &amp;lt; 1_000_000 ; i++){
               counter.counterThenGet();
            }
              System.out.println(output + counter.getCount());
        } ;
    }
    public static void main(String[] args) {
        computeCounter();
    }
    private static void computeCounter(){
        Counter counter = new Counter() ;
        Thread threadOne = new Thread(getRunnable(counter , "Thread one count is: "));
        Thread threadTwo = new Thread(getRunnable(counter , "Thread two count is: "));
        threadOne.start();
        threadTwo.start();
    }
}
The following code increments the counter after each iteration:

public class Counter {
    private int count = 0 ;
    public void counterThenGet() {
        this.count++ ;
    }
    public long getCount() {
        return count;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Prevent Race Conditions
&lt;/h3&gt;

&lt;p&gt;A &lt;em&gt;critical section&lt;/em&gt; is where the race condition occurs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void counterThenGet() {
        this.count++ ; //CRITICAL SECTION
    }
The way to fix the critical section is to make it *atomic*, meaning that only one thread can execute within the critical section at a given time. Making the critical section atomic yields the *sequential access* to counter.

To make it atomic, wrap the section in a synchronized lock:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;public class CounterWithSynchronizedLock {&lt;br&gt;
    private int count = 0 ;&lt;br&gt;
    private final Object lock = new Object() ;&lt;br&gt;
    public void counterThenGet() {&lt;br&gt;
        synchronized (lock){&lt;br&gt;
            this.count++ ;&lt;br&gt;
        }&lt;br&gt;
    }&lt;br&gt;
    public long getCount() {&lt;br&gt;
        return count;&lt;br&gt;
    }&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Only a single thread can execute within the *lock** at a given time, avoiding a situation where two threads read the value of the counter, then increment it. Whatever thread is going to be executed will read the value, increment it, and write it back as a single atomic operation.

## The Importance of Visibility in Multithreading
The importance of *visibility* (the memory that an executing thread can see once it’s written) in multithreaded applications cannot be belabored. When thread 1 writes to the memory before thread 2 reads it, the result is a race condition. It’s therefore imperative for Java developers to design, write, and test multithreaded Java applications with the basic tools of thread synchronization:

- **Using a synchronized keyword**: A synchronized keyword ensures that an unlock happens before every subsequent lock on the same monitor.
- **Using a volatile keyword**: A volatile keyword ensures that a write to a variable happens before subsequent reads of that variable.
- **Static initialization**: Static initialization ensures that the entire program is executed once when the class is first accessed and creates an instance of it. This is done by the class loader so that the JVM guarantees thread safety.

## Debugging Race Conditions
There are a couple of ways to debug multithreaded Java applications, but we’ll focus on the three most common ways here.

### 1. Run Code as Sequential Code
Not every bug is related to race conditions, so it’s possible that debugging in a sequential environment would be easier. Alter your code so that it runs sequentially in order to make sure that the bug does not appear in a sequential run.

For example, `#program omp` parallel for:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;public void doSomething(){&lt;br&gt;
for (int i = 0; i &amp;lt; n; i++)&lt;br&gt;
{&lt;br&gt;
 // some code here&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
Becomes &lt;code&gt;#pragma omp parallel&lt;/code&gt; for num_thread(N)&lt;/p&gt;

&lt;p&gt;public void doSomething(){&lt;br&gt;
OMP.setNumThreads(N);&lt;br&gt;
//omp parallel for&lt;br&gt;
for (int i = 0; i &amp;lt; n; i++)&lt;br&gt;
{&lt;br&gt;
 // some code here&lt;br&gt;
}&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;### 2. Use Log Statements
From within a thread, use logging statements to output debug information to the debugger so that you can form a post-mortem chain that can be followed. For example:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;LOG.debug(PrintStringDataFromObject)&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;


### 3. Use IntelliJ Debugging Tools
Using the [IntelliJ IDEA debugger](https://lightrun.com/debugging/how-to-debug-remotely-in-intellij/), you can **test multithreaded code and reproduce race condition bugs**.

In our multithreading example, the two threads share a counter. Each thread makes a million iterations while incrementing the counter at each iteration consequentially. This would mean that both threads should give you 2 million iterations in total.

To test this scenario, use breakpoints as provided by IntelliJ IDEA.

Set a breakpoint at the getter that fetches the counter.

![Public Class Counter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sftlmd6jbkncjr7al4xz.png)

You will then configure the breakpoint to only suspend the thread in which it was hit. This suspends both threads at the same line. To do this, right-click on the breakpoint, then click **Thread**.

![Public Long GetCount](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cy4escuwgbrcomf0f5tu.png)

To initiate debugging, click **Run** near the **RaceConditionExample** class and select **Debug**.

![Run Race Condition Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zvj0jdlb2amwmfra0j9i.png)

Thread 1 prints a result to the window console that is not 2 million. This is an expected result.

![Race Condition Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k66bctjvz598tthl5bzb.png)

Resume the thread by pressing F9 or clicking the **Resume** button in the upper left of the **Debug** window.

![Race Condition Example Solution 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppmtwilzh2chqyxjert8.png)

From the results, you can see that race conditions are realized. The second thread should be 2 million but instead 1.9 million is printed.

Now run the second code with atomic implementation of the critical section and observe the differences.

![Race Condition Example Solution 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7st4kqlkc8vgxk7prbe4.png)
![Race Condition Example Solution 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3aiq8658upxevc6diuua.png)
From the images above, notice that your race condition bug has been solved and your second iteration totals to 2 million, a result that your code anticipated as the correct output.

## Conclusion

Multithreading has lots of advantages, but can quickly become a debugging nightmare. Mastering the art of debugging is one of the most useful skills that you as a Java developer can use to make your development process smooth.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>tutorial</category>
      <category>java</category>
      <category>devops</category>
    </item>
    <item>
      <title>How Culture Impacts Technology Choice: A Review of Netflix’s Use of Microservices</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Mon, 31 May 2021 09:56:28 +0000</pubDate>
      <link>https://forem.com/eyalk100/how-culture-impacts-technology-choice-a-review-of-netflix-s-use-of-microservices-38l</link>
      <guid>https://forem.com/eyalk100/how-culture-impacts-technology-choice-a-review-of-netflix-s-use-of-microservices-38l</guid>
      <description>&lt;p&gt;My friend Itiel Shwartz is the CTO and co-founder of Komodor, a startup building the next-gen troubleshooting platform for Kubernetes. He wrote an article examining how &lt;a href="https://segment.com/blog/goodbye-microservices/"&gt;Netflix's use of microservices&lt;/a&gt; has completely transformed and revolutionized the streaming industry as we know it. He is an avid public speaker that loves talking about things like infrastructure, Kubernetes, Python observability, and R&amp;amp;D culture. &lt;/p&gt;

&lt;p&gt;I recently had the opportunity to read the book “&lt;a href="https://www.amazon.com/No-Rules-Netflix-Culture-Reinvention/dp/1984877860%23:~:text=Drawing%2520on%2520hundreds%2520of%2520interviews,most%2520innovative%252C%2520imaginative%252C%2520and%2520successful"&gt;No Rules Rules: Netflix and the Culture of Reinvention&lt;/a&gt;” by Reed Hastings and Erin Meyer of Netflix, and it dawned on me that while this book wasn’t at all focused on Netflix’s technology, the global company-wide culture had a significant impact on its technology choices. The book focuses on the many times Netflix had to reinvent itself and transform its business in order to revolutionize the entertainment industry. This revolution was made possible by an equally radical and formerly unheard of approach to a company culture that not only influenced how we build technology today but also thinks about company culture on a global scale.&lt;/p&gt;

&lt;p&gt;Needless to say, Netflix’s technology choices went on to influence the way the entire industry thinks about architecture built for massive scale. In this post, I’d like to take a look at how Netflix’s culture was the backbone that enabled its bleeding edge technology decisions — and specifically microservices. Some of what I write here is actually the direct influence of my own personal love-hate relationship with &lt;a href="https://thenewstack.io/category/microservices/"&gt;microservices&lt;/a&gt;. This book afforded me a newfound perspective on how to succeed at building challenging technology architectures to enable the business, by ensuring the right cultural mechanisms are in place first.  I’ll posit that if not for Netflix’s unique approach to company culture, their technology choices would not have been possible either, and ultimately neither would their success.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Backstory
&lt;/h2&gt;

&lt;p&gt;So just to dive into my inspiration for this post a bit more, my love-hate relationship with microservices began when I was a software engineer at eBay trying to tame a crazy monster of a monolith. It was so complex and vast and no one really understood all of it, that I learned how truly difficult it is to break up a monolith that is the beating heart of a business.&lt;/p&gt;

&lt;p&gt;Before kickstarting &lt;a href="https://komodor.com/"&gt;Komodor&lt;/a&gt;, I had a couple more opportunities to work on building microservices. The first was a gradual breakdown of a monolith, and the other was building a microservices architecture from the ground up. All of this experience provided me the opportunity to build the architecture that would drive our business from day one at my new venture, and I try to apply everything I have learned all the time.&lt;/p&gt;

&lt;p&gt;And just so we’re on the same page, if you need a refresher on microservices, a great place to start would be this &lt;a href="https://martinfowler.com/articles/microservices.html"&gt;foundational piece&lt;/a&gt; by Martin Fowler of ThoughtWorks. Another good read would be this newer piece by &lt;a href="https://segment.com/blog/goodbye-microservices/"&gt;Segment&lt;/a&gt;, which provides a much more practical perspective on migrating to microservices and the challenges involved.&lt;/p&gt;

&lt;h2&gt;
  
  
  Netflix’s 6 Principles of Building Culture AND Great Technology
&lt;/h2&gt;

&lt;p&gt;So how does this all come together? In their book Reed Hastings and Erin Meyer outline the core cultural principles that made their success possible, I’d like to compare these side by side with the cultural practices that enable engineering organizations to successfully deploy and maintain microservices architecture — which wasn’t actually the premise behind the book, but it certainly got me thinking about the places that engineering and culture intersect.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Principle One: Build Up Talent Density
&lt;/h3&gt;

&lt;p&gt;Netflix did not compromise on talent when it came to hiring. It hired the best possible people for each position, which was the foundation to their success. This is true by orders of magnitude when it comes to microservices architecture. Microservices require a great capacity for learning, as the people maintaining the architecture will continuously encounter new challenges and problems they’ve never confronted before. If we’ll be completely honest, it is just not possible for all developers and DevOps engineers to be the best in their field.&lt;/p&gt;

&lt;p&gt;While some companies have some pretty great engineers, Netflix has world-class engineers. This made it possible for Netflix to overcome challenges that many other engineers likely wouldn’t have had the capacity to work through as pioneers of complex architecture. It had some of the best engineers in the world working on the newly discovered challenges microservices surfaced, they overcame these and later enabled the industry to do so as well by sharing from this experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Second Principle: Begin Removing Controls
&lt;/h3&gt;

&lt;p&gt;Netflix’s radical approach to culture can be seen in the most basic of company guidelines from expenses through vacation approvals, employee trust was built-in to the culture as a foundational principle. That said, this was only made possible by having the right infrastructure in place to support this culture as well.  We’ll get into that later.&lt;/p&gt;

&lt;p&gt;This cultural practice is one of the core factors that can influence the success of managing microservices architecture at companies that are not Netflix. I’ve found that even companies that have made the decision to go down the microservices route do so while old processes and mechanisms still exist, and this highly hinders the ability to properly take advantage of the migration. If companies still maintain rules like approvals for each new change or commit introduced into a system, or even reverting changes, they essentially have a distributed monolith culture.&lt;/p&gt;

&lt;p&gt;So on the one hand, they have an architecture that can scale autonomously — but their people can’t. You need to trust your people to make the right decisions in order to extract the real benefits and velocity microservices make possible. Without this inherent trust and autonomy, you’ll essentially have the worst of both worlds. Netflix took this approach with all things, not just engineering, and it repaid them kindly in achieving success.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Third Principle: Maximize Candor Using Feedback Circles
&lt;/h3&gt;

&lt;p&gt;Many times the decision to move to microservices is a top-down decision. What oftentimes happens is that the decision-makers don’t really have any concept of the complexity of the task at hand — breaking up their architecture into smaller and smaller pieces. On the flip side, those who need to execute on the top-down decision don’t have the agency to influence the process. The move to microservices often surfaces a lot of complications, where things that previously worked suddenly stop working. A critical piece in moving quickly and resolving these issues, is short feedback loops.&lt;/p&gt;

&lt;p&gt;At Netflix, they were required to raise a flag and communicate problems when they surfaced, whereas other companies often do not enable a culture of such candor. Companies that don’t have an atmosphere that enables this kind of communication and candor will be set up for failure with complex architectures, where their teams will constantly be firefighting problems instead of architecting more long-term solutions built on collaborative thinking and communication as oftentimes the voices of the people in the trenches aren’t heard.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Fourth Principle: Build Supporting Infrastructure
&lt;/h3&gt;

&lt;p&gt;To be successful, you need to know that as a first step you’ll be spending a lot of time in building supporting tools for your developers and DevOps teams to enable them to be productive in this transformation.&lt;/p&gt;

&lt;p&gt;Like all “shift left” practices, if you only remember to do so after the fact, you will find it costing you 100x in time, resources, and even budget to build the supporting mechanisms to enable the teams to succeed. Succeeding with a loosely coupled architecture, that requires a lot of trust in your engineers’ decision-making, requires you to provide those at the bottom of the chain with more “powers.” To support their innovative approach to expense reporting and vacation requests for example, Netflix built the proper checks and balances into the system in advance, to ensure on the one hand that it couldn’t be abused, but that it could also scale with them as they grow and maintain this critical piece of their culture.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Fifth Principle: Celebrate Success and Sunshine Failures
&lt;/h3&gt;

&lt;p&gt;I think the industry as a whole learned the importance of celebrating successes, and today nearly every organization that prides itself on its company culture has some way of demonstrating appreciation for good work. However, on the flip side, one thing that companies can still learn from Netflix is their approach to failures. At Netflix failures are not brushed under the rug, they are analyzed, to be able to learn from each experience in order for the organization to grow and evolve, and not make the same mistakes twice.&lt;/p&gt;

&lt;p&gt;When you migrate to microservices you are going to have A LOT of failures at first, and if you don’t take the opportunity to learn from these, you will be destined to repeat the same mistakes. In the spirit of this pillar at Netflix, in a landscape of many partial successes and common failures — it is important to be self-aware and have the sensitivity to learn from these failures to figure out the root cause, and ultimately how to fix it, so it doesn’t repeat itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Sixth Principle: Leading with Context, not Control
&lt;/h3&gt;

&lt;p&gt;With monolithic architecture, it is very easy to have control, as there is only one service and everyone for the most part understands what is happening in their domain and aligns themselves to the practices in place. With microservices engineering management simply cannot understand everything that is happening in the system as a whole, and each team needs to have a high degree of autonomy. That’s why transparency is extremely important coupled with providing a lot of context around what is happening, when it comes to being able to make decisions in this fast-moving engineering environment.&lt;/p&gt;

&lt;p&gt;With microservices, it is impossible to micromanage and therefore you have to provide the general vision and direction and trust that your teams will align to these shared goals. Netflix understood how to do this really well, and this instilled a bottom-up joint purpose that fueled much of their success.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Have Learned
&lt;/h2&gt;

&lt;p&gt;So basically to wrap it up, microservices has proven to be a very powerful architecture to power modern, complex business, but you need to remember that to achieve success with technical architecture, it is no less important to “engineer your culture” (yet another great Netflix mantra). You need to have a good understanding of the culture you need to have in place to support distributed, advanced microservices architecture and for everything to ultimately work as expected. Having the technology without the culture will just result in many unhappy and overworked engineers.&lt;/p&gt;

&lt;p&gt;Great culture without modern engineering and architecture practices results in frustration in the inability to move at the desired velocity and deliver services as rapidly as engineers would like. Advanced architecture without the culture sets you up for failure, as you will not be able to capitalize on the benefits of microservices. So if you put in the effort to craft a truly great culture from the ground up, this will be foundational in enabling your people to thrive.&lt;/p&gt;

&lt;p&gt;So eventually when we build great culture alongside an excellent product, this will drive those who are together with us in our purpose to get creative, and will repay us generously in both innovation and business.&lt;/p&gt;

</description>
      <category>microservices</category>
    </item>
    <item>
      <title>8 tips to an effective code review checklist</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Sun, 16 May 2021 11:23:01 +0000</pubDate>
      <link>https://forem.com/eyalk100/8-tips-to-an-effective-code-review-checklist-3mlh</link>
      <guid>https://forem.com/eyalk100/8-tips-to-an-effective-code-review-checklist-3mlh</guid>
      <description>&lt;p&gt;Uri Shamay is a close friend and wunderkind with a wealth of experience in the devops field both as a founder and lead developer for a number of organizations. He wrote an excellent post detailing some of the most important aspects to remember when creating a code review checklist, and why it is so important in the development cycle.&lt;/p&gt;

&lt;p&gt;Code review is the best way to maintain a high level of code quality. The code review acts not only as a gatekeeper for bad code but also as an incentive for coders to improve their skills, learn, and scrutinize their own work. Code giants like Google use code review on everything added to the codebase.&lt;/p&gt;

&lt;p&gt;Most coders don’t use a checklist. At least not a formalized one. And definitely not a checklist as a tool produced by a team or a company that is used uniformly by all coders and reviewers. They might be using a mental checklist they have created for themselves. But this checklist may have major flaws if it is not discussed, designed, and maintained by multiple people. Checklists you can find on the internet are too long and too abstract for anyone to actually use. That is why, &lt;strong&gt;if you’re going to use a checklist, you should build your own&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why use a checklist?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Code reviews need to produce changes. If they do not, they might as well not happen&lt;/strong&gt;. This can lead to one of the biggest &lt;a href="https://www.brandonsavage.net/the-pitfalls-of-code-review-and-how-to-fix-them/" rel="noopener noreferrer"&gt;pitfalls of code reviews&lt;/a&gt;. Falling into a nitpicking session in search of something to change. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe48s6k7xeeuwvoidhsvc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe48s6k7xeeuwvoidhsvc.jpg" alt="Source: CommitStrip.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By using a checklist, the reviewers can stick to what’s important, and find those changes in the big things. Checklists also help reviewers make sure they don’t forget anything important. &lt;/p&gt;

&lt;h2&gt;
  
  
  When should you use a code review checklist?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A &lt;a href="https://spectralops.io/blog/8-tips-to-an-effective-code-review-checklist-with-xls-template/" rel="noopener noreferrer"&gt;checklist can be a tool&lt;/a&gt; you build to improve your code reviews, or it can be more of an established company-wide practice&lt;/strong&gt;. Either way, a checklist can be used both by the coder submitting code for review and by the person doing the review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Preparing a code for review is an important step and a checklist allows the coder to take a step back and look at their code more objectively before handing the code on to the reviewer&lt;/strong&gt;. I’d go so far as to say that a checklist can benefit the coder more than the reviewer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Top tips to building an effective code review checklist
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Mind the length
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;When building a code review checklist it is important to consider the length&lt;/strong&gt;. If a checklist is too short it is unlikely to be a true checklist and cover the important things. But if a checklist is too long? It is just going to be ignored, as it would be too tedious to use.&lt;/p&gt;

&lt;p&gt;The right size for your team might not be the same as for another. However, as a rule of thumb, 3-5 major issues and another 7-10 more entries focused or smaller issues would be a size I’d recommend.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Start from the basics
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.evoketechnologies.com/blog/code-review-checklist-perform-effective-code-reviews/" rel="noopener noreferrer"&gt;There&lt;/a&gt; &lt;a href="https://www.michaelagreiler.com/code-review-checklist-2/" rel="noopener noreferrer"&gt;are&lt;/a&gt; &lt;a href="https://www.codementor.io/blog/code-review-checklist-76q7ovkaqj" rel="noopener noreferrer"&gt;many&lt;/a&gt; &lt;a href="https://www.codegrip.tech/productivity/the-ultimate-code-review-checklist/" rel="noopener noreferrer"&gt;code&lt;/a&gt; &lt;a href="https://dzone.com/articles/the-8-part-guide-to-better-code-review-checklists" rel="noopener noreferrer"&gt;review&lt;/a&gt; checklists out there. Some are a long list of questions and some are broad topics you should make sure to touch on. &lt;strong&gt;Most of those issues are simply good design principles any coder should be aware of and manage while writing code. It makes sense that those would be the focus of checklists&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, I find it unhelpful to have a checklist item that asks if the code in question is good design. Instead, &lt;strong&gt;I recommend including items that encourage focusing on the reasons the code was written in the first place, or give a different lens through which to review the code&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Prepare your code
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Before you even get any explanation from the coder, ask yourself “Is this code self-explanatory?&lt;/strong&gt;” I’m a great proponent of &lt;a href="https://blog.hackbrightacademy.com/blog/writing-self-documenting-code/" rel="noopener noreferrer"&gt;self-documenting code&lt;/a&gt;. But &lt;strong&gt;even if your coding style incorporates comments the code should be human-readable&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Having to read the code without any explanation forces the reviewer to make sure they can understand the code without someone explaining it to them. &lt;strong&gt;If any part of the code requires explanation to be understood, it might be best to break it down into smaller pieces of code or add a comment&lt;/strong&gt;. With this item on the checklist, the reviewer can simply tell the coder that they did not understand the code. The coder can clarify, but they will know that they need to make the code clearer.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Affective vs effective code
&lt;/h3&gt;

&lt;p&gt;Once you understand what the code does, you must ask: &lt;strong&gt;does the code change achieve its goal simply and effectively?&lt;/strong&gt; People are very protective of their code, and as such will be reluctant to throw out their work and find a different solution. But if you can suggest a more effective code change? You should bring that to the attention of the coder.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Communicate effectively
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;How you communicate your proposal in a checklist is very important to whether or not it would be accepted&lt;/strong&gt;. I find it best to ask a guiding question and let developers come up with alternative solutions. That way it is still their idea, and it will be met with less resistance. Remember, &lt;strong&gt;code reviews are not about showing your colleague how smart you are, it is about making the code as good as possible&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Don’t neglect dependencies
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;An often overlooked part of code review are Dependencies&lt;/strong&gt;. It is easy to overlook a new dependency or a code in a package it doesn’t belong in. &lt;strong&gt;Putting this item on a checklist makes sure that this issue is not missed&lt;/strong&gt;. This can also make the code review faster as any issues of dependencies could be resolved by the coder before submitting the code for review.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Consider company-specific issues
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cvp7fxmftpwmvxc9o8l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5cvp7fxmftpwmvxc9o8l.png" alt="Source:evoketechnologies.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I could go on and list an endless number of issues that may or may not apply to your specific codebase. &lt;strong&gt;At the end of the day, your checklist needs to be tailor-made for your needs&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Does your company hold valuable information for customers? Could secrets have made their way into your codebase? Make sure you &lt;a href="https://spectralops.io/blog/why-we-need-developer-tools-for-security-and-not-security-tools-for-developers/" rel="noopener noreferrer"&gt;check security&lt;/a&gt;. Is your code highly modular, components used by many different areas of the code? Make sure everything is properly decoupled. If your company uses unit testing? Then you must make sure that the scope of the automated testing is comprehensive. Is the code change in a performance-intensive area of the software? Profiling could be a key item on your checklist.&lt;/p&gt;

&lt;p&gt;And so on and so forth.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Iterate and improve
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Like any design in software or otherwise, a checklist should improve over time&lt;/strong&gt;. Put the checklist itself on the agenda of a meeting. Get feedback from everyone using it to find ways to improve it. Don’t forget to also get input from anyone that is not using it. This can help you find out why and how it can be made more accessible to them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sometimes a one size fit all solution will not work&lt;/strong&gt;. Maybe another department needs a different checklist, and maybe someone in your team needs a different approach to help them improve the quality of their code review. Either way, checklists are not usually written in stone and, as such, grow and evolve with your codebase.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F40cncytshj5cy75hs02h.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F40cncytshj5cy75hs02h.jpeg" alt="Source: imagemag.ru"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Creating the right code review checklist you need to do some research about what checklists are available, and take them apart. Find the items on them that speak to your company’s design and integrate them.&lt;/p&gt;

&lt;p&gt;But most importantly, &lt;strong&gt;keep improving your code review checklist&lt;/strong&gt;. The chances of you getting a perfect checklist the first time you build one are slim. Find out which &lt;a href="https://spectralops.io/blog/top-10-most-common-java-vulnerabilities-you-need-to-prevent/" rel="noopener noreferrer"&gt;bugs&lt;/a&gt; have slipped through the review process and add the necessary checklist items to prevent them. And cut out items that don’t produce any changes. Think of it as freeing some unused objects in your reviewer’s memory.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tutorial</category>
      <category>dev</category>
    </item>
    <item>
      <title>How to Debug Remotely in IntelliJ</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Mon, 10 May 2021 09:36:55 +0000</pubDate>
      <link>https://forem.com/eyalk100/how-to-debug-remotely-in-intellij-11o8</link>
      <guid>https://forem.com/eyalk100/how-to-debug-remotely-in-intellij-11o8</guid>
      <description>&lt;p&gt;Milan Bhardwaj is a colleague and an AI/ML software engineering adept with a wealth of experience solving real-world challenges with scalable solutions. He has driven many development cycles from inception to completion and wrote this expert and well-thought-out guide to &lt;a href="https://lightrun.com/debugging/how-to-debug-remotely-in-intellij/"&gt;remote debugging in IntelliJ environments&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Debugging is one of the most critical aspects of software development cycles. Developers not only leverage it to find and fix errors, but also to uncover potential performance issues in the code. Being able to debug is a core skill every developer needs to have in order to provide valuable, scalable solutions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For applications running on remote servers and computers, developers turn to remote debugging to identify issues that can’t be produced locally.&lt;/strong&gt; For example, you might run a smaller instance of your database locally to test with, but when pushed to a production load, bugs might surface related to &lt;a href="https://spectralops.io/blog/top-10-data-modeling-tools-for-2021/"&gt;large data sets&lt;/a&gt;. Or you might not run the same permission and firewall restrictions when developing locally that you do in production. This can lead to bugs that are impossible to reproduce locally without a significant investment in tooling.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With remote debugging, you can remotely control a target utilizing a debugger instance running on a different machine.&lt;/strong&gt; The debugger instance, also referred to as a debug engine, runs on the same machine as the routine you’re debugging. Your local machine runs the debugger’s UI while the remote system runs both the debug engine and the target routine.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://lightrun.com/debugging/debugging-microservices-in-production-an-overview/"&gt;Remote debugging&lt;/a&gt; is particularly useful for a few reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controlling the flow of execution:&lt;/strong&gt; It’s vital that developers understand the context of a bug as it manifests, and remote debugging affords that with features like pausing, resuming, and executing the program step by step.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Debugging in production environments:&lt;/strong&gt; Troubleshooting problems on remote testing and production servers is no easy task. Running a debugger directly on the server where the application is running comes with its own set of limitations. Production servers usually run in strict environments where convenient developer tools are absent. Remote debugging is the perfect solution.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Catering to multiple deployment scenarios:&lt;/strong&gt; Developers can debug a variety of complex deployment scenarios, from a single, standalone application to distributed applications and clusters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Debugging remotely in practice
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Most programming languages support some kind of remote debugging with the right tooling in place.&lt;/strong&gt; Java includes several options for remote debugging, including integrations with most IDEs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this tutorial, you’ll see how to set up remote debugging&lt;/strong&gt; on &lt;a href="https://www.jetbrains.com/idea/"&gt;IntelliJ&lt;/a&gt; so you can effectively debug applications deployed to staging and production machines when necessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up remote debugging on IntelliJ
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.jetbrains.com/"&gt;JetBrains’&lt;/a&gt; &lt;strong&gt;IntelliJ is one of the most intelligent integrated development environments (IDEs), used by more than&lt;/strong&gt; &lt;a href="https://snyk.io/blog/intellij-idea-dominates-the-ide-market-with-62-adoption-among-jvm-developers"&gt;62 percent of Java developers&lt;/a&gt;. It offers developers out-of-the-box Java debugging functionalities that facilitate efficient, sustainable solutions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a New Project and Class
&lt;/h3&gt;

&lt;p&gt;The first step is to properly set up and configure your &lt;a href="https://lightrun.com/java/the-complete-guide-to-java-string-replace/"&gt;Java project&lt;/a&gt; in IntelliJ. If you have not set up a Java program before, &lt;a href="https://www.jetbrains.com/help/idea/creating-and-running-your-first-java-application.html#get-started"&gt;read the IntelliJ documentation&lt;/a&gt; to understand how you can create and configure a new Java project.&lt;/p&gt;

&lt;p&gt;In order to demonstrate remote debugging, create a new class. Click &lt;strong&gt;src&lt;/strong&gt; on the sidebar, hover on &lt;strong&gt;New&lt;/strong&gt;, then click &lt;strong&gt;Java class&lt;/strong&gt;. For this example, we’ll create a class named &lt;code&gt;My_Numbers&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tb5UuFCV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7j1st60jse9d7hw16jn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tb5UuFCV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7j1st60jse9d7hw16jn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have created the Java class, it’s time to write some code. Populate the &lt;strong&gt;Main&lt;/strong&gt; method with the below example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class My_Numbers { public static void main(String[] args) { System.out.println("Initiating"); for (int num = 0; num &amp;lt; 100; num++) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } System.out.println(num); } System.out.println("Done"); } }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code is a basic example that prints numbers from 0 to 100. While it’s a simple example, it will be enough to showcase remote debugging without adding too much complexity. You’ll add a [(&lt;a href="https://www.jetbrains.com/help/idea/using-breakpoints.html)debug"&gt;https://www.jetbrains.com/help/idea/using-breakpoints.html)debug&lt;/a&gt; breakpoint] in later steps.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring Remote Debugging
&lt;/h3&gt;

&lt;p&gt;Now that you have a Java project and test class ready, you need to set up a debugging configuration in IntelliJ. Navigate to &lt;strong&gt;Run&lt;/strong&gt;, then &lt;strong&gt;Edit Configurations&lt;/strong&gt;. Click &lt;strong&gt;Add New Configuration (+)&lt;/strong&gt; and choose &lt;strong&gt;Remote JVM Debug&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Fill in the following information to describe your remote debugging environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name: In this case, &lt;code&gt;My_Numbers_remote_debug&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Host: This field is for the address of the machine where the host app will run. Since we’re running on the same server in this example, it should be &lt;code&gt;localhost&lt;/code&gt;, but if you want to debug a remote server (eg, &lt;code&gt;192.168.18.46&lt;/code&gt;), you must enter the IP address here.&lt;/li&gt;
&lt;li&gt;Port: &lt;code&gt;5005&lt;/code&gt; in this case. This port should be available, so pick one that your server supports.&lt;/li&gt;
&lt;li&gt;Command-line arguments: You can copy the generated command-line arguments and paste them to the command line where JVM is active. You can copy the string for now (eg, -&lt;code&gt;agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005)&lt;/code&gt; and store it for later use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9Johf1nd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c7vgmitqij2yqgjuqhu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9Johf1nd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0c7vgmitqij2yqgjuqhu.png" alt="run / debug config"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now IntelliJ knows where to access your remote (or local) application for debugging, but you still need to package and run the Java app to enter a debugging session.&lt;/p&gt;

&lt;h3&gt;
  
  
  Running the application
&lt;/h3&gt;

&lt;p&gt;Set up the host application by &lt;a href="https://www.jetbrains.com/help/idea/compiling-applications.html#see-results"&gt;packaging your application as a JAR&lt;/a&gt; and use the previously generated argument string directly in the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;code&amp;gt;&amp;lt;span class="hljs-keyword"&amp;gt;java &amp;lt;/span&amp;gt;-&amp;lt;span class="hljs-keyword"&amp;gt;jar &amp;lt;/span&amp;gt;-agentlib:&amp;lt;span class="hljs-keyword"&amp;gt;jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 &amp;lt;/span&amp;gt;remote-&amp;lt;span class="hljs-built_in"&amp;gt;debug&amp;lt;/span&amp;gt;-application-sample.&amp;lt;span class="hljs-keyword"&amp;gt;jar&amp;lt;/span&amp;gt;
&amp;lt;/code&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, click &lt;strong&gt;Run&lt;/strong&gt;, then &lt;strong&gt;Edit Configuration&lt;/strong&gt;, then select &lt;code&gt;My_Numbers&lt;/code&gt; from under the &lt;strong&gt;Application&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CUA-LVsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpfmml4qbec7zzte6ht2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CUA-LVsC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cpfmml4qbec7zzte6ht2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In &lt;strong&gt;Modify Options&lt;/strong&gt;, select &lt;strong&gt;Add VM options&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4OgoA_uO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ows42n0by4zna08lfp7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4OgoA_uO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0ows42n0by4zna08lfp7.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under the VM options field, paste the argument string that you copied previously.&lt;/p&gt;

&lt;p&gt;With the necessary setup in place, you are ready to run the application. Right-click in the text editor and click &lt;strong&gt;Run&lt;/strong&gt; &lt;code&gt;My_Numbers.main()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the program output, you’ll see &lt;code&gt;Listening for transport dt_socket at address: 5005&lt;/code&gt;, followed by your app’s output. The first line states that the debug agent is active and the program is ready to accept incoming debugger connections.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tmFJ9MO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eig1zgj32kaa2rkoufjg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tmFJ9MO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eig1zgj32kaa2rkoufjg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding a Breakpoint
&lt;/h3&gt;

&lt;p&gt;Now that your Java program is running, you can add a breakpoint and attach it to the process. &lt;strong&gt;Breakpoints allow you to set a place in the code where execution will pause so you can inspect memory, variables, and the state of your program.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can set a line breakpoint by clicking on the gutter at the line of your choice. For this example, click line 10 and set the breakpoint with the condition &lt;code&gt;num = 50&lt;/code&gt;. The program is suspended as soon as the breakpoint condition meets the condition.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D49DcPu9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65jgtbfusfnyaqnzctxt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D49DcPu9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/65jgtbfusfnyaqnzctxt.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point, you can perform relevant debugging actions, including expression evaluation and stepping, among other tasks. These actions will work whether you’re running locally on your machine or connecting to a remote instance of your Java application.&lt;/p&gt;

&lt;p&gt;There is no denying that with distributed applications, it has become easier to manage, scale, and divide the workload. However, the architecture makes it much difficult to detect/reproduce bugs since it’s challenging to trace anomalies back to the source or replicate complex production environments. Remote debugging with &lt;a href="https://www.jetbrains.com/idea/"&gt;IntelliJ&lt;/a&gt; can help developers identify bugs and reproduce errors across every stage of the software deployment lifecycle.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>java</category>
    </item>
    <item>
      <title>Getting Started with Spring Boot Actuator</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Thu, 22 Apr 2021 13:16:11 +0000</pubDate>
      <link>https://forem.com/eyalk100/getting-started-with-spring-boot-actuator-33m1</link>
      <guid>https://forem.com/eyalk100/getting-started-with-spring-boot-actuator-33m1</guid>
      <description>&lt;p&gt;Vikram Arucharmy wrote an engaging and well-constructed post about implementing and using the &lt;a href="https://lightrun.com/best-practices/getting-started-with-spring-boot-actuator/" rel="noopener noreferrer"&gt;spring boot actuator&lt;/a&gt;. For anyone creating a production application or otherwise, it's a must.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Any production application needs to be monitored for its uptime.&lt;/strong&gt; Let’s say you’ve developed a stock market statistics application, for example, using &lt;a href="https://spring.io/projects/spring-boot" rel="noopener noreferrer"&gt;Spring Boot&lt;/a&gt; for your client. This application has to be up all the time while the stock market is open. If it’s down at a crucial time, it could mean huge losses for relevant stakeholders. In addition to being monitored for uptime, an application like this would probably even need a hotline support team that can be notified immediately if the application goes down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8i89vnaae703sgv2d3x.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs8i89vnaae703sgv2d3x.jpg" alt="spring boot logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By using the &lt;a href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html" rel="noopener noreferrer"&gt;Spring Boot Actuator&lt;/a&gt; as a dependency, you can enable health status indicators to monitor your application’s status without any explicit implementation.&lt;/strong&gt; We’ll get into many of its other functionalities as well in this tutorial, along with tips on how to use it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Spring Boot Actuator?
&lt;/h2&gt;

&lt;p&gt;In mechanical terms, an actuator is a mechanical device used to move or control something. Similarly, &lt;strong&gt;the Spring Boot Actuator can be used to monitor and manage your Spring Boot application. All the actuator features are exposed to end users using the HTTP &lt;a href="https://searchapparchitecture.techtarget.com/definition/API-endpoint" rel="noopener noreferrer"&gt;endpoints&lt;/a&gt;, communication channels that allow two software programs to communicate with each other.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Spring Boot Actuator has several production-ready features&lt;/strong&gt; available:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring&lt;/strong&gt;: Checking the &lt;a href="https://lightrun.com/debugging/debugging-microservices-the-ultimate-guide/" rel="noopener noreferrer"&gt;health status of the application&lt;/a&gt; to ensure that it’s running as expected without any problems. Actuator lets you check the health of the application by using the &lt;code&gt;/health/&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging&lt;/strong&gt;: Writing &lt;a href="https://lightrun.com/best-practices/how-to-understand-log-levels/" rel="noopener noreferrer"&gt;log messages&lt;/a&gt; about events that occur during the runtime of the application. Actuator helps you view log messages and configure log levels during runtime using the &lt;code&gt;/loggers/&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tracing&lt;/strong&gt;: Logging all the HTTP requests to your application. It can be useful to understand how users are interacting with your application. Actuator helps you trace the HTTP requests by using the &lt;code&gt;/httptrace/&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics&lt;/strong&gt;: Measuring the performance and managing the memory footprint of your application. Actuator provides the useful metrics of your application by using the &lt;code&gt;/metrics/&lt;/code&gt; endpoint.&lt;/li&gt;
&lt;li&gt;Auditing: Logging the authentication and authorization events of the application when Spring security is in action. This can help ensure the security and compliance of the application as well as define the lockdown mechanisms after n number of invalid login attempts. You can read more about &lt;a href="https://www.baeldung.com/spring-boot-authentication-audit" rel="noopener noreferrer"&gt;Audit events here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs0ylhkrbolcwmm0k8elw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs0ylhkrbolcwmm0k8elw.png" alt="spring boot modules"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Importing and Configuring the Spring Boot Actuator
&lt;/h2&gt;

&lt;p&gt;Import the Spring Boot Actuator to your Spring application, and let’s see how to enable and expose the endpoint to end users.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;spring-boot-actuator&lt;/code&gt; module helps you enable all the production-ready features in your Spring Boot application. Hence, you need to add this module in your dependencies. You can add the following code to the &lt;code&gt;&amp;lt;dependencies&amp;gt;&lt;/code&gt; section of the pom.xml file, if you’re using &lt;a href="https://maven.apache.org/" rel="noopener noreferrer"&gt;Maven-based&lt;/a&gt; projects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;  
    &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-boot-starter-actuator&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re using &lt;a href="https://gradle.org/" rel="noopener noreferrer"&gt;Gradle&lt;/a&gt;, you can use the following declaration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies { 
implementation 'org.springframework.boot:spring-boot-starter-actuator' 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, you’ll see how to enable and expose the endpoints.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enabling Endpoints
&lt;/h2&gt;

&lt;p&gt;All the &lt;a href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-endpoints" rel="noopener noreferrer"&gt;available Actuator endpoints&lt;/a&gt; are enabled by default except the shutdown endpoint.&lt;/p&gt;

&lt;p&gt;You can enable the Actuator endpoints using the &lt;a href="https://www.tutorialspoint.com/spring_boot/spring_boot_application_properties.htm" rel="noopener noreferrer"&gt;Spring Boot Application&lt;/a&gt; properties file. To enable the endpoint, set the &lt;code&gt;property management.endpoint&lt;/code&gt;.&lt;code&gt;&amp;lt;id&amp;gt;.enabled&lt;/code&gt; in the Spring Boot properties file. The &lt;code&gt;&amp;lt;id&amp;gt;&lt;/code&gt; must be replaced with the actual endpoint name, which needs to be enabled or disabled.&lt;/p&gt;

&lt;p&gt;Use the below property in the properties file to enable the &lt;code&gt;shutdown&lt;/code&gt; endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;management.endpoint.shutdown.enabled=true
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;&amp;lt;id&amp;gt;&lt;/code&gt; is replaced with the endpoint name &lt;code&gt;shutdown&lt;/code&gt; to enable the &lt;code&gt;shutdown&lt;/code&gt; endpoint.&lt;/p&gt;

&lt;p&gt;If you want to disable an endpoint, you can use the same property and assign the value &lt;code&gt;false&lt;/code&gt; in place of &lt;code&gt;true&lt;/code&gt;. This will disable the endpoint and remove the service from the application context.&lt;/p&gt;

&lt;p&gt;If you don’t want to enable all the endpoints by default, you can disable that by using the property &lt;code&gt;enabled-by-default&lt;/code&gt; as shown below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;management.endpoints.enabled-by-default=false
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now all the endpoints will be disabled, and you can enable each desired endpoint by setting its enabled property to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exposing and Hiding Endpoints
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Exposing an endpoint means making it accessible to the end users using the different technologies, namely &lt;a href="https://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/jmx.html" rel="noopener noreferrer"&gt;JMX&lt;/a&gt; and Web (HTTP endpoints)&lt;/strong&gt;. Actuator endpoints may consist of sensitive information about the application and data. Hence, utmost care needs to be taken as to which endpoints should be exposed using which technology to make the application secure.&lt;/p&gt;

&lt;p&gt;Similar to enabling the endpoints, you need to use the Spring Boot &lt;code&gt;application.properties&lt;/code&gt; file to expose the endpoints. The property to expose the endpoint is &lt;code&gt;management.endpoints&lt;/code&gt;.&lt;code&gt;&amp;lt;technology&amp;gt;.exposure.include&lt;/code&gt;. Here &lt;em&gt;technology&lt;/em&gt; must be replaced with either &lt;em&gt;jmx&lt;/em&gt; or &lt;em&gt;web&lt;/em&gt; to expose the endpoints in that specific technology.&lt;/p&gt;

&lt;p&gt;You can find the &lt;a href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-endpoints-exposing-endpoints" rel="noopener noreferrer"&gt;endpoints exposed by default here&lt;/a&gt;. Only the enabled endpoints are exposed by default.&lt;/p&gt;

&lt;p&gt;The property to hide the endpoint is &lt;code&gt;management.endpoints.&amp;lt;technology&amp;gt;.exposure.exclude&lt;/code&gt;. Once again, &lt;em&gt;technology&lt;/em&gt; must be replaced with either &lt;em&gt;jmx&lt;/em&gt; or &lt;em&gt;web&lt;/em&gt; to hide the endpoints in that specific technology.&lt;/p&gt;

&lt;p&gt;A few things to note:&lt;/p&gt;

&lt;p&gt;All the enabled endpoints are exposed in JMX by default, whereas only&lt;br&gt;
&lt;code&gt;health&lt;/code&gt; and &lt;code&gt;info&lt;/code&gt; endpoints are exposed in Web&lt;br&gt;
The &lt;code&gt;exclude&lt;/code&gt; property takes precedence over the &lt;code&gt;include&lt;/code&gt; property. If you have by any chance configured both &lt;code&gt;exclude&lt;/code&gt; and &lt;code&gt;include&lt;/code&gt; for any of the endpoints, then the endpoint will be excluded.&lt;br&gt;
Now when you build your Spring Boot application, you’ll have all the relevant monitoring features readily available. You can easily consume it by using the defined endpoints.&lt;/p&gt;
&lt;h2&gt;
  
  
  Calling an Endpoint
&lt;/h2&gt;

&lt;p&gt;In this section, you’ll learn how to call an endpoint using your browser and what will be the output of each endpoint. The following example assumes that your Spring Boot application is running in your local machine and the default port &lt;code&gt;8080&lt;/code&gt;. Hence the application base URL would be &lt;code&gt;http://localhost:8080/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, you must know what endpoints are available as part of the Spring Boot Actuator in order to call it. The Spring Boot Actuator has a hypermedia (a discovery page) endpoint available under the URL &lt;code&gt;&amp;lt;application_base_user&amp;gt;/actuator/&lt;/code&gt; where all the available endpoints will be displayed.&lt;/p&gt;

&lt;p&gt;To call the hypermedia endpoint &lt;code&gt;/actuator/&lt;/code&gt;, use &lt;code&gt;http://localhost:8080/actuator&lt;/code&gt;. You’ll see the following output with all the available endpoints displayed as a JSON text:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "_links":{
      "self":{
         "href":"http://localhost:8080/actuator",
         "templated":false
      },
      "beans":{
         "href":"http://localhost:8080/actuator/beans",
         "templated":false
      },
      "caches-cache":{
         "href":"http://localhost:8080/actuator/caches/{cache}",
         "templated":true
      },
      "caches":{
         "href":"http://localhost:8080/actuator/caches",
         "templated":false
      },
      "health":{
         "href":"http://localhost:8080/actuator/health",
         "templated":false
      },
      "health-path":{
         "href":"http://localhost:8080/actuator/health/{*path}",
         "templated":true
      },
      "info":{
         "href":"http://localhost:8080/actuator/info",
         "templated":false
      },
      "conditions":{
         "href":"http://localhost:8080/actuator/conditions",
         "templated":false
      },
      "configprops":{
         "href":"http://localhost:8080/actuator/configprops",
         "templated":false
      },
      "env":{
         "href":"http://localhost:8080/actuator/env",
         "templated":false
      },
      "env-toMatch":{
         "href":"http://localhost:8080/actuator/env/{toMatch}",
         "templated":true
      },
      "loggers":{
         "href":"http://localhost:8080/actuator/loggers",
         "templated":false
      },
      "loggers-name":{
         "href":"http://localhost:8080/actuator/loggers/{name}",
         "templated":true
      },
      "heapdump":{
         "href":"http://localhost:8080/actuator/heapdump",
         "templated":false
      },
      "threaddump":{
         "href":"http://localhost:8080/actuator/threaddump",
         "templated":false
      },
      "metrics-requiredMetricName":{
         "href":"http://localhost:8080/actuator/metrics/{requiredMetricName}",
         "templated":true
      },
      "metrics":{
         "href":"http://localhost:8080/actuator/metrics",
         "templated":false
      },
      "scheduledtasks":{
         "href":"http://localhost:8080/actuator/scheduledtasks",
         "templated":false
      },
      "mappings":{
         "href":"http://localhost:8080/actuator/mappings",
         "templated":false
      }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, let’s walk through the different endpoints and their defined purposes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Health
&lt;/h3&gt;

&lt;p&gt;Use the &lt;code&gt;health&lt;/code&gt; endpoint to monitor the health of your Spring Boot application. It’ll return the current application status. &lt;strong&gt;This endpoint can also be used by monitoring tools to keep track of application status and notify the team when the application goes down.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This &lt;code&gt;health&lt;/code&gt; endpoint uses the &lt;a href="https://github.com/spring-projects/spring-boot/tree/v2.4.3/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthContributor.java" rel="noopener noreferrer"&gt;HealthContributor&lt;/a&gt; defined in the application context to collect the application health. When more than one HealthContirbutors is available, the final system health is derived by the &lt;code&gt;StatusAggregator&lt;/code&gt;, which aggregates all the available health statuses from an ordered list. The first available status will be considered the overall health status.&lt;/p&gt;

&lt;p&gt;You can check all the &lt;a href="https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready-health-indicators" rel="noopener noreferrer"&gt;auto-configured HealthContributors&lt;/a&gt; here.&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;http://localhost:8080/actuator/health&lt;/code&gt; to consume the health endpoint. You’ll see the following JSON output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{"status":"UP","groups":["custom"]}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s break that down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;status&lt;/strong&gt;: Provides the status of application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;UP&lt;/strong&gt;: The application is running fine.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;groups&lt;/strong&gt;: Provides the name of the group to which this status is assigned. Groups organize different health indicators.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;custom&lt;/strong&gt;: The current health status’s group.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metrics
&lt;/h3&gt;

&lt;p&gt;Metrics can be used to measure the performance of your production application. Spring Boot Actuator supports dependency management and auto configuration for the &lt;a href="https://micrometer.io/" rel="noopener noreferrer"&gt;Micrometer&lt;/a&gt;, a metrics façade that supports most &lt;a href="https://micrometer.io/docs" rel="noopener noreferrer"&gt;popular monitoring systems&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To know all the available metrics in your Spring boot application, use &lt;code&gt;http://localhost:8080/actuator/metrics&lt;/code&gt;. You’ll see all the available metrics names as given:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "names":[
      "http.server.requests",
      "jvm.buffer.count",
      "jvm.buffer.memory.used",
      "jvm.buffer.total.capacity",
      "jvm.classes.loaded",
      "jvm.classes.unloaded",
      "jvm.gc.live.data.size",
      "jvm.gc.max.data.size",
      "jvm.gc.memory.allocated",
      "jvm.gc.memory.promoted",
      "jvm.gc.pause",
      "jvm.memory.committed",
      "jvm.memory.max",
      "jvm.memory.used",
      "jvm.threads.daemon",
      "jvm.threads.live",
      "jvm.threads.peak",
      "jvm.threads.states",
      "logback.events",
      "process.cpu.usage",
      "process.start.time",
      "process.uptime",
      "system.cpu.count",
      "system.cpu.usage",
      "tomcat.sessions.active.current",
      "tomcat.sessions.active.max",
      "tomcat.sessions.alive.max",
      "tomcat.sessions.created",
      "tomcat.sessions.expired",
      "tomcat.sessions.rejected"
   ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you’ll learn how to consume a specific metric from the available metrics. Let’s take &lt;code&gt;http.server.requests&lt;/code&gt; and &lt;code&gt;jvm.memory.used&lt;/code&gt; metrics as an example.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http.server.requests&lt;/code&gt; returns the number of http server requests processed by the application. Use &lt;code&gt;http://localhost:8080/actuator/metrics/http.server.requests&lt;/code&gt; to find out the number of http requests. You’ll see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "name":"http.server.requests",
   "description":null,
   "baseUnit":"seconds",
   "measurements":[
      {
         "statistic":"COUNT",
         "value":19.0
      },
      {
         "statistic":"TOTAL_TIME",
         "value":1.923151205
      },
      {
         "statistic":"MAX",
         "value":0.0
      }
   ],
   "availableTags":[
      {
         "tag":"exception",
         "values":[
            "None",
            "ResponseStatusException"
         ]
      },
      {
         "tag":"method",
         "values":[
            "GET"
         ]
      },
      {
         "tag":"uri",
         "values":[
            "/actuator/metrics/{requiredMetricName}",
            "/employees/{id}",
            "/employees",
            "NOT_FOUND",
            "/actuator/health",
            "/actuator/health/{*path}",
            "/actuator/metrics"
         ]
      },
      {
         "tag":"outcome",
         "values":[
            "CLIENT_ERROR",
            "SUCCESS"
         ]
      },
      {
         "tag":"status",
         "values":[
            "404",
            "200"
         ]
      }
   ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;COUNT&lt;/code&gt; shows the number of HTTP requests handled by your application and &lt;code&gt;TOTAL_TIME&lt;/code&gt; shows the total time taken to process them.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;jvm.memory.used&lt;/code&gt; returns the used memory metric of your application. Use &lt;code&gt;http://localhost:8080/actuator/metrics/jvm.memory.used&lt;/code&gt; to find the used memory. You’ll see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
   "name":"jvm.memory.used",
   "description":"The amount of used memory",
   "baseUnit":"bytes",
   "measurements":[
      {
         "statistic":"VALUE",
         "value":5.6238416E7
      }
   ],
   "availableTags":[
      {
         "tag":"area",
         "values":[
            "heap",
            "nonheap"
         ]
      },
      {
         "tag":"id",
         "values":[
            "Survivor Space",
            "Eden Space",
            "Metaspace",
            "Code Cache",
            "Tenured Gen"
         ]
      }
   ]
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;VALUE&lt;/code&gt; shows the value of the JVM memory used by your Spring boot application in &lt;code&gt;Bytes&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can explore all the available metrics by appending the metric name in the URL &lt;code&gt;http://localhost:8080/actuator/metrics/&lt;/code&gt; to find the different useful metrics of your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;For any business-critical application, monitoring, tracing, logging, and auditing are crucial to ensure uptime and that the application is consumed appropriately by users. With &lt;a href="https://spring.io/guides/gs/actuator-service/" rel="noopener noreferrer"&gt;Spring Boot Actuator&lt;/a&gt;, you can enable these functionalities in your application in a matter of minutes, simply by adding it as a dependency in your Maven POM file.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>programming</category>
    </item>
    <item>
      <title>8 Top Git Security Issues &amp; What To Do About Them</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Sun, 04 Apr 2021 19:05:04 +0000</pubDate>
      <link>https://forem.com/eyalk100/8-top-git-security-issues-what-to-do-about-them-5h5h</link>
      <guid>https://forem.com/eyalk100/8-top-git-security-issues-what-to-do-about-them-5h5h</guid>
      <description>&lt;p&gt;&lt;a href="https://spectralops.io/blog/github-vs-gitlab/" rel="noopener noreferrer"&gt;Git&lt;/a&gt; is the most popular software version control (SVC) standard used by developers today. That doesn’t make it the most secure. Whether you’re using GitLab, GitHub, or a locally hosted Git server; there are many security issues that can sneak up on you and start a snowball effect of unpleasant repercussions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this post, we’ll review just how secure Git is (or rather isn’t). We will demonstrate why and how serious Git security issues can be. Then, we’ll list the eight most common Git security issues, and what you can do about them&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How secure is Git?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;At its core, Git is not built for security but for collaboration. As such, it is not secure but can be made secure through the use of tools and best practices&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Self-hosting a Git server is a security nightmare. &lt;strong&gt;If you are not an experienced maven in Git server configuration? You are probably not qualified to maintain a self-hosted Git solution hosting sensitive data&lt;/strong&gt;. There are too many opportunities to exploit a misconfigured or unpatched Git server. So you may very well end up leaving &lt;a href="https://www.darkreading.com/risk/nissan-source-code-leaked-via-misconfigured-git-server/d/d-id/1339845" rel="noopener noreferrer"&gt;a lot of holes&lt;/a&gt; for hackers to exploit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Even hosted Git services such as GitHub or GitLab offer limited security&lt;/strong&gt;. Such services offer an easy-to-use interface with enhanced access controls. However, their convenience and ease-of-use can prove to be a hindrance as well, often leading to human error. This especially true when code-commits are not properly screened by secret detection tools.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xqdg0w0butp83vkvim8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xqdg0w0butp83vkvim8.png" alt="Perfecting your relationship with corporate security"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Git security matters
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;With many companies relying on Git for code management, Git has become a popular attack vector for hackers&lt;/strong&gt;. There are numerous cautionary tales depicting the outcome of badly configured or insecure Git management. These are just the tip of the iceberg:&lt;/p&gt;

&lt;h2&gt;
  
  
  Two databases and a Spreadsheet
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An employee at the Albert Einstein Hospital in Sao Paulo accidentally committed a sensitive spreadsheet file to a public GitHub repository&lt;/strong&gt;. The spreadsheet in question included login credentials to two governmental databases. The first database contained private information on patients suffering from mild COVID-19 conditions. The second database held full patient hospitalization data. &lt;/p&gt;

&lt;p&gt;Overall, &lt;strong&gt;the &lt;a href="https://securereading.com/data-of-16-million-brazilian-covid-19-patients-exposed-online/" rel="noopener noreferrer"&gt;leak exposed&lt;/a&gt; personally identifying medical records of over 16 million Brazilian patients. The list included high-profile patients such as the Brazilian President, his family, 7 Ministers, and 17 state Governors&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Nissan takes a wrong turn
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Automotive giant Nissan’s North America division suffered a massive &lt;a href="https://spectralops.io/blog/6-steps-data-breach-response-plan/" rel="noopener noreferrer"&gt;data breach&lt;/a&gt; because of bad password hygiene&lt;/strong&gt;. The company’s self-hosted Git server was misconfigured to use the default “admin/admin” password. This left the door completely open for &lt;a href="https://www.zdnet.com/article/nissan-source-code-leaked-online-after-git-repo-misconfiguration/" rel="noopener noreferrer"&gt;hackers to step right in&lt;/a&gt;. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq58h8t8hl6o30th6n169.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq58h8t8hl6o30th6n169.png" alt="Nissan data breach dump torrent contents"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(Source: ZDNet)&lt;br&gt;
&lt;strong&gt;The leak was only discovered after the source code behind Nissan’s mobile apps, websites and internal tools surfaced on hacking forums and Telegram groups&lt;/strong&gt;. Thus, potentially leading to future exploits based on vulnerabilities hackers may discover within the pilfered code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Don’t leave the doors open, Mercedes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A Swiss software engineer &lt;a href="https://www.zdnet.com/article/mercedes-benz-onboard-logic-unit-olu-source-code-leaks-online/" rel="noopener noreferrer"&gt;discovered&lt;/a&gt; a GitLab instance hosting onboard logic unit source code used in Daimler’s Mercedes Benz vans&lt;/strong&gt;. The badly configured GitLab instance allowed anyone to register a developer account. &lt;/p&gt;

&lt;p&gt;With a developer account in hand, &lt;strong&gt;over 580 Git repositories became easily accessible&lt;/strong&gt;. This potentially enabled new and dangerous remote-takeover attacks based on vulnerabilities in the logic unit’s &lt;a href="https://spectralops.io/blog/8-proven-strategies-to-protect-your-code-from-data-leaks/" rel="noopener noreferrer"&gt;leaked source code&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pay, or your Git gets it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Nearly 400 private Git repositories were &lt;a href="https://www.zdnet.com/article/a-hacker-is-wiping-git-repositories-and-asking-for-a-ransom/" rel="noopener noreferrer"&gt;held up for ransom&lt;/a&gt; by a hacker looking to cash out on poor security practices&lt;/strong&gt;. The hacker scanned the internet, searching for websites with exposed Git configuration files that included login credentials. &lt;/p&gt;

&lt;p&gt;They could then correlate these credentials with accounts on multiple Git hosting services where users were insecurely using the same login credentials. The &lt;strong&gt;malefactor encrypted the repositories and demanded a ransom&lt;/strong&gt; by Bitcoin, threatening to take the vulnerable repositories public if the victims made no payment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Healthcare providers are full of leaks
&lt;/h2&gt;

&lt;p&gt;A Netherland security researcher, wondering if private patient healthcare information was easy to access online, did not take long to discover that &lt;strong&gt;healthcare developers did not take care of their code’s health&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;The search took only 10 minutes &lt;a href="https://www.hipaajournal.com/healthcare-data-leaks-on-github-credentials-corporate-data-and-the-phi-of-150000-patients-exposed/" rel="noopener noreferrer"&gt;using fairly simple searches&lt;/a&gt; on public GitHub repositories. With it, &lt;strong&gt;the researcher discovered hardcoded passwords enabling access to over 150,000 patient records across 9 healthcare entities in the United States&lt;/strong&gt; (AccQData, MaineCare, MedPro Billing, Physician House Calls, Shields Health Care Group, Texas VirMedica, Waystar, Xybion).&lt;/p&gt;

&lt;h2&gt;
  
  
  Top 8 Git security issues &amp;amp; what to do about them
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Hardcoded sensitive data
&lt;/h3&gt;

&lt;p&gt;It’s all too convenient for a developer to store passwords, tokens, and authentication keys right in the code where such credentials are used. It’s just so tempting to save them where they are most accessible in case an issue arises. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;While convenient, hardcoded secrets are possibly the &lt;a href="https://www.beyondtrust.com/blog/entry/hardcoded-and-embedded-credentials-are-an-it-security-hazard-heres-what-you-need-to-know" rel="noopener noreferrer"&gt;worst security practice&lt;/a&gt; currently plaguing software development&lt;/strong&gt;. No one is perfect. People make mistakes and forget past actions (such as temporarily storing passwords in code). People also often share code. Sometimes, they do so accidentally and at other times, intentionally as part of a collaboration. In such cases, long-forgotten secrets, still embedded in code, can easily leak and even get indexed online search engines.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffin495rmpzynp7gkxrfi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffin495rmpzynp7gkxrfi.png" alt="Software engineer: "&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;There is no technical reason to use hardcoded authentication credentials. To prevent leaks, be sure to train developers to use secure coding practices&lt;/strong&gt;. At the same time, you should ensure that security tools are integrated into the development process. These can monitor the workflow to &lt;a href="https://spectralops.io/" rel="noopener noreferrer"&gt;prevent secrets from accidentally being committed&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Insecure Directories (.git/config)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;When self-hosting a Git server, it is vitally important to secure the “.git” directory. A publicly accessible Git directory can allow malicious actors to clone the repository. Then they can scan it for secrets in the code or within historical records&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj8ym79n0c64c6q67rbg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpj8ym79n0c64c6q67rbg.png" alt="Index of /.git"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other dangers lie in possible exploits residing in the source code itself. For example, SQL injection attacks are a lot easier to develop when you can review the source code of the target application. Furthermore, it is not enough to just deny directory listing access. &lt;strong&gt;Hackers with knowledge of Git’s directory structure can potentially &lt;a href="https://medium.com/swlh/hacking-git-directories-e0e60fa79a36" rel="noopener noreferrer"&gt;bypass directory listing limitations&lt;/a&gt;, easily accessing secure files directly&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The only way to validate if a self-hosted Git installation is secure? Is by trying to penetrate it using the same techniques a hacker would. &lt;strong&gt;You must verify the “.git” directory and its sub-directories (especially “.git/config”) are not publicly accessible in any way or form and that all communication with the repository is performed over secure-HTTP (HTTPS)&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Ignored .gitignore
&lt;/h3&gt;

&lt;p&gt;The “.gitignore” file is an important security feature utilized by Git. The .gitignore configuration file informs Git of files that should or should not be included when the developer commits code to a repository. &lt;/p&gt;

&lt;p&gt;Unfortunately, some developers are not trained in using .gitignore correctly. For example, a developer may add “.gitignore” to a folder name, assuming Git would ignore the folder. Another example would be a developer dropping an empty “.gitignore” file inside a folder, thinking the entire folder would be ignored.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To properly secure code commits, you must first understand &lt;a href="https://www.pluralsight.com/guides/how-to-use-gitignore-file" rel="noopener noreferrer"&gt;how “.gitignore” works&lt;/a&gt;. Then, the best “.gitignore” strategy to use is one of &lt;a href="https://dev.to/gajus/gitignore-mistake-that-everyone-makes-44kb"&gt;inclusion rather than exclusion&lt;/a&gt;&lt;/strong&gt;. You do not want to keep a list of files that must be skipped during a code commit. This is because more files may be added to the project over time, enabling secrets to leak if the “.gitignore” file is not consistently updated. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By using a “.gitignore” inclusion commit strategy only the specified files are committed to the repository&lt;/strong&gt;. This helps stops secrets from becoming accidentally exposed due to lacking “.gitignore” maintenance.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Unsigned commits
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;When committing code to a Git repository, you can easily see the author committing the code. However, unless the author used a GPG key to cryptographically sign the commit, you simply can’t trust what you’re seeing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is &lt;a href="https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html" rel="noopener noreferrer"&gt;fairly trivial&lt;/a&gt; for a developer with access to a repository to assign a code-commit they themselves performed to another developer on the project. A disgruntled employee can do this to inject a backdoor into the code, covering their track by assigning ownership of the code to another developer. &lt;/p&gt;

&lt;p&gt;Another exploit would be to assign a code commit to a more respected or higher-ranking member of the project’s development, hoping the new code would be integrated with less oversight.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When code commits are signed, a “verified” icon appears next to the commit log entry. This ensures every member of the project knows the code was committed by the original author and was not tampered with in any way.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Insecure pipeline configuration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;An insecure CD/CI pipeline can lead to secrets leaking or placed at risk by various processes&lt;/strong&gt; such as pull requests coming from forks of your repository or CD/CI VMs left operating unattended. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://circleci.com/blog/security-best-practices-for-ci-cd/" rel="noopener noreferrer"&gt;Securing the pipeline&lt;/a&gt; requires holding secrets with very limited exposure. Beyond training developers to use proper security practices when storing secrets; you should integrate tools or online services into the CD/CI pipeline to provide an additional layer of protection.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You should employ Tools and Online Services to secure the build process and help store secrets as encrypted data, utilizing “just-in-time” decryption to limit exposure during storage and transport. This additional security layer is even more important when protecting extremely sensitive materials such as code-signing certificates.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Git vulnerabilities
&lt;/h3&gt;

&lt;p&gt;While known vulnerabilities in Git are usually resolved quickly by the Git development team? &lt;strong&gt;When self-hosting Git, it is up to the site administrator to patch Git with the latest security updates as soon as they are released&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is quite easy to locate Git servers through a web search, and unpatched servers are an easy mark for any hacker. To emphasize the dangers of an unpatched server, you only need to look at &lt;a href="https://www.cvedetails.com/cve/CVE-2017-14867/" rel="noopener noreferrer"&gt;CVE-2017-14867&lt;/a&gt;. The vulnerability allowed attackers with Git-shell access to execute OS-level commands on unpatched systems – a recipe for a complete system takeover.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Unpatched software
&lt;/h3&gt;

&lt;p&gt;Git is often used in combination with other tools or services to automate, secure, and provide analytics throughout the CD/CI pipeline. &lt;strong&gt;These days, hackers are not limiting themselves to directly hacking a target. It’s often easier and even more lucrative to perform a &lt;a href="https://www.sans.org/blog/what-you-need-to-know-about-the-solarwinds-supply-chain-attack" rel="noopener noreferrer"&gt;supply-chain attack&lt;/a&gt;&lt;/strong&gt; on tools or services to compromise multiple entities that employ them. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To limit exposure to supply chain attacks, it is vitally important to apply tool-chain security patches as soon as they are released. You should also limit online service access to the minimum required for reliable operations, and of course, perform regular backups.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Inaccurate access permissions
&lt;/h3&gt;

&lt;p&gt;As shown by the Mercedes example, &lt;strong&gt;badly configured permissions can provide an access point to every Git repository on the server&lt;/strong&gt;. In the Mercedes case, the server automatically granted full access to anyone who just signed up for a developer account. In other cases, more subtle access permissions configuration errors may result in persons accessing data they are not authorized to. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When setting up access permissions, you must define access roles on a per-repository basis to ensure only developers with valid access credentials are allowed to interact with the repository.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3fxxhpsrj74u9c6jbl8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg3fxxhpsrj74u9c6jbl8.jpg" alt="4 Elements of A Great Serverless Application Deployment Strategy — HADII  Technology"&gt;&lt;/a&gt;&lt;br&gt;
Do not take Git security lightly. You have a lot to lose when your source code or intellectual data are compromised. To use Git in a production environment where code must remain secure? Secrets should never leak and security practices and policies must be consistently enforced.&lt;/p&gt;

</description>
      <category>git</category>
      <category>security</category>
    </item>
    <item>
      <title>Microservices vs APIs: One Doesn’t Always Imply the Other</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Tue, 16 Mar 2021 17:12:18 +0000</pubDate>
      <link>https://forem.com/eyalk100/microservices-vs-apis-one-doesn-t-always-imply-the-other-4ph4</link>
      <guid>https://forem.com/eyalk100/microservices-vs-apis-one-doesn-t-always-imply-the-other-4ph4</guid>
      <description>&lt;p&gt;Allan McGregor, a 15-year veteran software engineer, entrepreneur, and good friend wrote an &lt;a href="https://lightrun.com/best-practices/microservices-vs-apis/"&gt;engaging and insightful article&lt;/a&gt; on the oft-misconstrued relationship between Microservices and APIs.&lt;/p&gt;

&lt;p&gt;When it comes to conversations around application architecture or working with integrations between applications, you’ve likely heard a couple terms pop up a few times: &lt;em&gt;microservice&lt;/em&gt; and &lt;em&gt;APIs&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;You might also have run across the common misconception that microservices are just a way to implement APIs so they can communicate with each other. As you’ll see in this article, there are alternative ways to architect our microservice applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s explore the concepts of microservices and APIs individually—what they are and how they’re used—and then I’ll show you how to combine both microservices and APIs into a more robust architecture.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What Are APIs?
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;APIs, or application programming interfaces, are what allow an application to communicate with other applications&lt;/strong&gt;. Strictly speaking, an API is a group of protocols and standards that define how two applications share and modify each other’s data.&lt;/p&gt;

&lt;p&gt;The definition for &lt;em&gt;API&lt;/em&gt; has evolved and expanded over time. The term first originated to describe an interface meant only for end-user-facing programs, known as &lt;em&gt;application programs&lt;/em&gt;. But API has come to mean something much broader. The term includes hardware interfaces and, of course, web APIs. In fact, &lt;em&gt;web API&lt;/em&gt; is the most common application of the term nowadays.&lt;/p&gt;

&lt;h3&gt;
  
  
  Web APIs
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;If you’re using any web application today, you use APIs&lt;/strong&gt;. They’re what enable the software integrations, allowing for many different systems to talk to each other (B2B communication). From banking and online shopping to social media and online streaming, APIs are powering most of our digital lives.&lt;/p&gt;

&lt;p&gt;Now, &lt;strong&gt;APIs usually send and receive data through HTTP requests&lt;/strong&gt;. There are several different types of protocols and API styles, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;REST&lt;/li&gt;
&lt;li&gt;SOAP&lt;/li&gt;
&lt;li&gt;GraphQL&lt;/li&gt;
&lt;li&gt;gRPC&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main difference between each resides in the architecture and, in cases like gRPC, in the communication protocol. Let’s take a closer look at one of the oldest and most common types of API: RESTful APIs.&lt;/p&gt;

&lt;h3&gt;
  
  
  RESTful APIs
&lt;/h3&gt;

&lt;p&gt;The term &lt;strong&gt;REST, or Representation State Transfer, was defined by&lt;/strong&gt;  &lt;a href="https://en.wikipedia.org/wiki/Roy_Fielding"&gt;Roy Fielding&lt;/a&gt;  in his 2000 Ph.D. dissertation “Architectural Styles and the Design of Network-based Software Architectures.” &lt;strong&gt;Fielding outlined six architectural constraints required to define a RESTful system:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client-Server Architecture&lt;/li&gt;
&lt;li&gt;Stateless&lt;/li&gt;
&lt;li&gt;Cacheable&lt;/li&gt;
&lt;li&gt;Uniform Interface&lt;/li&gt;
&lt;li&gt;Layered System&lt;/li&gt;
&lt;li&gt;Code on Demand&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;For an API to be RESTful, it must include these aspects:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A base URI, such as

&lt;code&gt;https://api.example.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
&lt;li&gt;Use of semantic HTTP methods (GET, PUT, POST, and DELETE)&lt;/li&gt;
&lt;li&gt;Media type definition for state transition of data elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a real-life example, think of shopping online. When you’re ready to check out, you see that the store gives you a couple of options to estimate shipping, commonly USPS, FedEx, or UPS.&lt;/p&gt;

&lt;p&gt;Since each one of those shipping carriers is a separate company with different rates, the online store will make an API call with the contents of your shopping cart (weight, volumetric size) and retrieve the available rates for you to select during checkout. Once your order is placed and ready to be fulfilled, the store might make another API call to create the final shipment with the shipping vendor.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;With APIs, applications can offer robust functionality without the need to implement everything from scratch.&lt;/strong&gt; Other examples of this include using your social media credentials for account creation or login, buying online tickets, or even ordering a ride-share.&lt;/p&gt;

&lt;h3&gt;
  
  
  External and Internal APIs
&lt;/h3&gt;

&lt;p&gt;APIs can be classified into two different categories: external and internal. The examples I’ve covered up to this point have been external, meaning APIs for third-party software developers and external use.&lt;/p&gt;

&lt;p&gt;That said, &lt;strong&gt;APIs don’t have to be publicly available. Internal APIs are used for communication between internal applications, for example, internal microservices.&lt;/strong&gt; With that in mind, let’s take a look at microservices next.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Microservices?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Microservices"&gt;Microservices&lt;/a&gt; are:&lt;/p&gt;

&lt;p&gt;Microservice architecture—a variant of the service-oriented architecture (SOA) structural style—arranges an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained, and the protocols are lightweight.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microservices are a style of software architecture used to divide different application functions into smaller “services.”&lt;/strong&gt; These services are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Highly maintainable and testable&lt;/li&gt;
&lt;li&gt;Loosely coupled&lt;/li&gt;
&lt;li&gt;Independently deployable&lt;/li&gt;
&lt;li&gt;Organized around business logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Microservice architecture is used to enable rapid, frequent, and reliable delivery of large and complex applications.&lt;/strong&gt; The granularity of these services might vary greatly from a couple of services with large boundaries to hundreds of smaller services with particular functions, in the case of some larger companies.&lt;/p&gt;

&lt;p&gt;To illustrate how a microservice architecture behaves in action, let’s take a step back and compare two different architectures for a flight booking app: monolith vs microservice.&lt;/p&gt;

&lt;h3&gt;
  
  
  Monolith
&lt;/h3&gt;

&lt;p&gt;According to  &lt;a href="https://en.wikipedia.org/wiki/Monolithic_application"&gt;Wikipedia&lt;/a&gt;, a monolith is:&lt;/p&gt;

&lt;p&gt;A monolithic application is self-contained and independent from other computing applications. The design philosophy is that the application is responsible not just for a particular task but can perform every step needed to complete a particular function.&lt;/p&gt;

&lt;p&gt;In essence, &lt;strong&gt;a monolith is a single application that contains all the elements and components of an application or service, from the presentation layer and business logic all the way down to the database communication.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7kSV6xLR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1615794855272/_y6_qu3EN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7kSV6xLR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1615794855272/_y6_qu3EN.png" alt="Sample monolith application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, our monolith is responsible for everything, including exposing an external API for third parties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monoliths are not necessarily bad or obsolete, and in specific scenarios, like a proof of concept or a simple web service, it might make sense to use a monolith.&lt;/strong&gt; But as soon as our application starts to grow in responsibilities and scope, it makes sense to move to a microservice architecture.&lt;/p&gt;

&lt;p&gt;Let’s take a look at the same application but this time using a microservice-based architecture:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HTt-kLiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1615794753268/57Y5-umbR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HTt-kLiH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1615794753268/57Y5-umbR.png" alt="Sample microservice application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a few key differences from our monolith approach:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We have broken down the business logic into different and separate services.&lt;/li&gt;
&lt;li&gt;The flight-booking service doesn’t have any dependencies with the database nor the frontend.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Each service has its own API, and the other services use that API to communicate with each other.&lt;/p&gt;
&lt;h2&gt;
  
  
  Microservices vs. APIs
&lt;/h2&gt;

&lt;p&gt;Before moving forward, let’s do a quick recap of what we’ve learned so far:&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;An API is the part of an application that allows other applications to request and send data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There are many different styles of APIs and protocols.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;em&gt;Microservices&lt;/em&gt; is a software architecture style that separates an application into smaller boundaries.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Microservices can communicate to each other through APIs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is often where confusion or misunderstanding can set in. Note that the &lt;strong&gt;APIs implemented by each service don’t have to be RESTful, or even use HTTP for that matter&lt;/strong&gt;; there are more efficient and faster alternatives.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One of these alternatives is gRPC, a universal RPC framework developed by Google.&lt;/strong&gt; gRPC is a high-performance, open-source, universal RPC framework that can run in any environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microservices could also communicate using the Event/Message system, which is entirely asynchronous and doesn’t need to wait for a response, thus avoiding coupling between our services.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each one of these communication methods, there are a few pros and cons to consider.&lt;/p&gt;

&lt;h2&gt;
  
  
  REST
&lt;/h2&gt;

&lt;p&gt;Pros:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Easy to understand and implement without previous experience&lt;/li&gt;
&lt;li&gt;Requests and responses are usually human-readable (JSON)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Widely adopted standard with native support from many frameworks and libraries&lt;br&gt;
Cons:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No standardized way to do things like versioning, search, and logical breakdown of endpoints&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Poor support and applicability for streaming&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;No standard schema for endpoints&lt;/p&gt;
&lt;h2&gt;
  
  
  gRPC
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Pros:&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Great speed due to the binary format&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Great support for streaming data bidirectionally&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supported by many languages (Java, Python, Scala) and allows for cross-language communication&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Higher learning curve, and additional knowledge required (eg, Protobuf)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Payloads are not human-readable and require additional tools for debugging&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Event/Message Driven&lt;br&gt;
&lt;strong&gt;Pros&lt;/strong&gt;:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fully asynchronous communication between services&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports many different message formats: JSON, protobuf, AVRO&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Can facilitate service decoupling&lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Application design using messages may be more complicated&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Additional message queue like Kafka, RabbitMQ or Pulsar is needed&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The asynchronous nature might make it harder to debug&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Making It All Work
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Those are a lot of options, but here’s the best part: they are not mutually exclusive. They can all work together in your application’s service architecture.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let’s take a final pass on our application diagram and apply what we’ve learned so far:&lt;/p&gt;

&lt;p&gt;Microservices application with more efficient communication&lt;/p&gt;

&lt;p&gt;There are a few changes from our previous microservice diagram:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We moved our REST API implementation to a fourth service.&lt;/li&gt;
&lt;li&gt;REST is now only used for communicating with our frontend app and any external developer or services.&lt;/li&gt;
&lt;li&gt;All the services are internally communicating using gRPC for better performance and handling large volumes of traffic.&lt;/li&gt;
&lt;li&gt;Additionally, the booking service and billing service are communicating using an Event/Message system for operations that can be asynchronous.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you can see, it’s possible to combine each communication style to leverage their benefits and strengths.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusions
&lt;/h3&gt;

&lt;p&gt;So now that we’ve gone over the definitions of microservices and APIs, hopefully, you’re more familiar with the connection between them.&lt;/p&gt;

&lt;p&gt;** APIs allow our applications to send and receive data with other applications or even external developers; there are many different communication protocols and styles of APIs. Microservices are an architectural pattern that allows us to organize our application into smaller services. By segmenting our application into smaller services each with a single responsibility, we can quickly scale, maintain, and develop complex systems. **&lt;/p&gt;

&lt;p&gt;Typically, microservices and APIs are applied together. For example, each microservice could contain an API. Through the API, the microservices will communicate with each other. However, this isn’t strictly necessary—services could use different communication strategies, like a message queue. Similarly, APIs don’t need to be implemented through microservices; for example, they could be part of a monolith application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Knowing the difference and understanding the synergy between both concepts should allow you to leverage both efficiently when architecting and building applications.&lt;/strong&gt; Companies like Netflix, Spotify, and Shopify have adopted this approach already.&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>architecture</category>
    </item>
    <item>
      <title>The Complete Guide to Java String Replace</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Mon, 01 Mar 2021 09:48:23 +0000</pubDate>
      <link>https://forem.com/eyalk100/the-complete-guide-to-java-string-replace-4jde</link>
      <guid>https://forem.com/eyalk100/the-complete-guide-to-java-string-replace-4jde</guid>
      <description>&lt;p&gt;&lt;a href="https://lightrun.com/java/the-complete-guide-to-java-string-replace/" rel="noopener noreferrer"&gt;A colleague of mine Vikram Aruchamy over at LightRun&lt;/a&gt; wrote an excellent, concise, and easy-to-use tutorial on using the &lt;code&gt;String.Replace()&lt;/code&gt; functionality in Java. I asked his permission to post his article here, and he graciously agreed. His post is a great resource to make sure you understand the utility behind these Java functionalities including examples.&lt;/p&gt;

&lt;p&gt;One of the most commonly used functionalities for String objects in Java is String replace. With &lt;code&gt;replace()&lt;/code&gt;, you can replace an occurrence of a &lt;code&gt;Character&lt;/code&gt; or &lt;code&gt;String&lt;/code&gt; literal with another &lt;code&gt;Character&lt;/code&gt; or &lt;code&gt;String&lt;/code&gt; literal.&lt;/p&gt;

&lt;p&gt;You might use the &lt;code&gt;String.replace()&lt;/code&gt; method in situations like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replacing special characters in a String (eg, a &lt;code&gt;String&lt;/code&gt; with the German character ö can be replaced with oe). This won’t change the meaning of the word, but it will help make the string more universally understood.&lt;/li&gt;
&lt;li&gt;Reading data from a CSV file with comma-separated values. The delimiters can be replaced with a space using the replace method to split the words.&lt;/li&gt;
&lt;li&gt;Handling URLs in Java. You may need to encode the string to replace special characters (eg, a space needs to be replaced with &lt;em&gt;%20&lt;/em&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Java, keep in mind that &lt;code&gt;String&lt;/code&gt; objects are immutable, which means the object cannot be changed once it’s created. &lt;code&gt;StringBuffer&lt;/code&gt; and &lt;code&gt;StringBuilder&lt;/code&gt; objects, on the other hand, are mutable, meaning they can be changed after they’re created. So, in some situations, &lt;code&gt;String.replace()&lt;/code&gt; might not be the best way to replace a character in a string.&lt;/p&gt;

&lt;p&gt;In this tutorial, you’ll learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How &lt;code&gt;String.replace()&lt;/code&gt;, &lt;code&gt;StringBuilder.replace()&lt;/code&gt;, &lt;code&gt;StringBuffer.replace()&lt;/code&gt; can be used to replace a specific character or a substring in a &lt;code&gt;String&lt;/code&gt; and when to use each of them.
What happens to the immutable &lt;code&gt;String&lt;/code&gt; object when &lt;code&gt;replace()&lt;/code&gt; or &lt;code&gt;replaceAll()&lt;/code&gt; is used.&lt;/li&gt;
&lt;li&gt;How &lt;code&gt;String.replaceAll()&lt;/code&gt; can replace all occurrences of a specific character or a substring in a String.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Using String.replace()
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;String.replace()&lt;/code&gt; is used to replace all occurrences of a specific character or substring in a given &lt;code&gt;String&lt;/code&gt; object without using regex. There are two overloaded methods available in Java for &lt;code&gt;replace()&lt;/code&gt;: String.replace() with Character, and String.replace() with CharSequence.&lt;/p&gt;

&lt;h3&gt;
  
  
  String.replace() with Character
&lt;/h3&gt;

&lt;p&gt;This method accepts the &lt;code&gt;oldChar&lt;/code&gt; and &lt;code&gt;newChar&lt;/code&gt;, then replaces all the &lt;code&gt;oldChar&lt;/code&gt; in the given string literal with the &lt;code&gt;newChar&lt;/code&gt; and returns a resultant &lt;code&gt;String&lt;/code&gt; object.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public String replace(char oldChar, char newChar)&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgbkczbb0n546pegw79fn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgbkczbb0n546pegw79fn.png" alt="Visual example of how the public String replace function works"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  String.replace() with CharSequence
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#replace-java.lang.CharSequence-java.lang.CharSequence-" rel="noopener noreferrer"&gt;This method&lt;/a&gt; accepts the target CharSequence and the replacement CharSequence, then replaces all the target CharSequence with the &lt;code&gt;replacement&lt;/code&gt; CharSequence and returns a resultant &lt;code&gt;String&lt;/code&gt; object.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/8/docs/api/java/lang/CharSequence.html" rel="noopener noreferrer"&gt;CharSequence&lt;/a&gt; is an &lt;a href="https://www.w3schools.com/java/java_interface.asp" rel="noopener noreferrer"&gt;interface&lt;/a&gt; in Java implemented by &lt;code&gt;String, StringBuffer, and StringBuilder&lt;/code&gt;. You can use any of these implementations in place of CharSequence.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public String replace(CharSequence target, CharSequence replacement)&lt;/code&gt;&lt;br&gt;
While the signatures are different, these two implementations of the &lt;code&gt;replace()&lt;/code&gt; method work much the same way.&lt;/p&gt;
&lt;h2&gt;
  
  
  String.replace() Examples
&lt;/h2&gt;

&lt;p&gt;Let’s use the &lt;code&gt;replace()&lt;/code&gt; method with the &lt;code&gt;Char&lt;/code&gt; types parameter to replace a single character. You’ll use only single quotes in the &lt;code&gt;replace()&lt;/code&gt; method parameters to denote &lt;code&gt;oldChar&lt;/code&gt; and &lt;code&gt;newChar&lt;/code&gt; as &lt;code&gt;Characters&lt;/code&gt;. Double quotes make the parameters a String.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/** * Method to demonstrate the Replace method using the Chars type parameter */
private static void useStringReplaceWithChar() {
  String sourceString = "The world is schön. This is a String with special Character ö";
  String replacedString = sourceString.replace('ö', 'o');
  System.out.println("Source String before replace : " + sourceString + "\n");
  System.out.println("Replaced String : " + replacedString + "\n");
  System.out.println("Source String after replace : " + sourceString);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you execute the program above, you’ll see this output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source String before replace : The world is schön. This is a String with special Character ö 
Replaced String : The world is schon. This is a String with special Character o 
Source String after replace : The world is schön. This is a String with special Character ö
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to note:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first line printed the source String with the special character &lt;strong&gt;ö&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;When we used the &lt;code&gt;replace()&lt;/code&gt; method, all occurrences of the special character &lt;strong&gt;ö&lt;/strong&gt; are replaced with &lt;strong&gt;o&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;With the &lt;code&gt;replace()&lt;/code&gt; method, the original String is not modified. It always returns a new String object.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you use the &lt;code&gt;replace()&lt;/code&gt; method with &lt;code&gt;CharSequence&lt;/code&gt; type parameters (denoted by double quotes instead of single):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;... 
String replacedString = sourceString.replace("ö", "oe"); 
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see similar output and the unmodified original String:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source String before replace : The world is schön. This is a String with special Character ö 
Replaced String : The world is schoen. This is a String with special Character oe 
Source String after replace : The world is schön. This is a String with special Character ö
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also use the &lt;code&gt;replace()&lt;/code&gt; method with the &lt;code&gt;StringBuilder&lt;/code&gt; implementation in place of &lt;code&gt;CharSequence&lt;/code&gt; types”:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
StringBuilder sourceStrBuilder = new StringBuilder("ö");
StringBuilder targetStrBuilder = new StringBuilder("oe");
String replacedString = sourceString.replace(sourceStrBuilder, targetStrBuilder);
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you execute this variation, you’ll see the same output as the previous example.&lt;/p&gt;

&lt;p&gt;While the &lt;code&gt;replace()&lt;/code&gt; method might be the obvious choice for most string replacement operations, it’s not the only option. In the next section, I’ll introduce the &lt;code&gt;replace()&lt;/code&gt; method in &lt;code&gt;StringBuilder&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using StringBuilder.replace()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuilder.html" rel="noopener noreferrer"&gt;StringBuilder&lt;/a&gt; is a mutable sequence of characters. It is not thread-safe; methods are not synchronized. It’ll replace the substring sequence in the range passed as index parameters with the replacement String.&lt;/p&gt;

&lt;p&gt;This is the method to use if you want to &lt;strong&gt;perform the replace operation in a single-threaded Java program.&lt;/strong&gt; You can also use it in multiple thread programs as well, but that’s not recommended because the &lt;a href="https://proandroiddev.com/synchronization-and-thread-safety-techniques-in-java-and-kotlin-f63506370e6d" rel="noopener noreferrer"&gt;methods are not synchronized&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;First, create a &lt;code&gt;StringBuilder&lt;/code&gt; initialized with a &lt;code&gt;String&lt;/code&gt; with the special character &lt;strong&gt;ö&lt;/strong&gt;, using the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String sourceString = "The world is schön. This is a String with special Character ö";
StringBuilder builder = new StringBuilder(sourceString);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, use the &lt;code&gt;replace()&lt;/code&gt; method with &lt;code&gt;StringBuilder&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;replace()&lt;/code&gt; method accepts three parameters: &lt;code&gt;startIndex&lt;/code&gt;, &lt;code&gt;endIndex&lt;/code&gt;, and the &lt;code&gt;replacementString&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;startIndex&lt;/code&gt; is the beginning index of the replacement in a String literal. It’s inclusive, which means if you specify 1, the index 1 of the String will be included in the replacement.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;endIndex&lt;/code&gt; is the ending index of the replacement in a String literal. It’s exclusive, which means if you specify 5, the index 5 of the String will not be included in the replacement. Replacements are made only through index 4.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;replacementString&lt;/code&gt; is the actual replacement String. The specified index range in the String literal will be replaced with this String.
The index of the character to be replaced is a required parameter, but you can use the &lt;code&gt;StringBuilder.indexOf()&lt;/code&gt; method to identify the index of the special character as shown here:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int indexOfUmlauts = builder.indexOf("ö");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have the index of the special characters in the &lt;code&gt;int&lt;/code&gt;, which can be passed to the replace method. The following example shows the full Java code for using the &lt;code&gt;StringBuilder.replace()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/** * Demonstrating the Replace method available in StringBuilder */
private static void useStringBuilderReplace() {
  String sourceString = "The world is schön. This is a String with special Character ö";
  StringBuilder builder = new StringBuilder(sourceString);
  int indexOfUmlauts = builder.indexOf("ö");
  System.out.println("Source String before replace : " + sourceString + "\n");
  System.out.println("Using StringBuilder.replace() " + builder.replace(indexOfUmlauts, indexOfUmlauts + 1, "oe") + "\n");
  System.out.println("String builder after replace : " + builder);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you execute the above code, you’ll see this output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source String before replace : The world is schön. This is a String with special Character ö 
Using StringBuilder.replace() : The world is schoen. This is a String with special Character ö 
String builder after replace : The world is schoen. This is a String with special Character ö
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few things to note:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first line printed the source String with the special String literal &lt;strong&gt;ö&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When the &lt;code&gt;StringBuilder.replace()&lt;/code&gt; method is used, only the characters specified in the &lt;code&gt;startIndex&lt;/code&gt; and &lt;code&gt;endIndex&lt;/code&gt; are replaced with &lt;strong&gt;o&lt;/strong&gt;. It doesn’t replace all the occurrences. You can see the character &lt;strong&gt;ö&lt;/strong&gt; at the end is not replaced.&lt;/li&gt;
&lt;li&gt;When the &lt;code&gt;StringBuilder.replace()&lt;/code&gt; method is used, the original &lt;code&gt;StringBuilder&lt;/code&gt; is modified. This is because &lt;code&gt;StringBuilder&lt;/code&gt; is mutable, and it’s changed directly.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Mutability might be desired in some cases, but be careful. It could be an unintended side effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using StringBuffer.replace()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.oracle.com/javase/1.5.0/docs/api/java/lang/StringBuffer.html" rel="noopener noreferrer"&gt;StringBuffer&lt;/a&gt; is a mutable sequence of characters. Similar to &lt;code&gt;StringBuilder.replace()&lt;/code&gt;, It’ll replace the substring sequence in the range passed as index parameters with the replacement String, but it’s thread-safe. Use this method when you want to perform the replace operation in a multi-threaded Java program.&lt;/p&gt;

&lt;p&gt;To begin, create a StringBuffer initialized with a String with the special character &lt;strong&gt;ö&lt;/strong&gt; similar to how you did with StringBuilder above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String sourceString = "The world is schön. This is a String with special Character ö";
StringBuffer buffer = new StringBuffer(sourceString);
The replace() method accepts three parameters:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;startIndex&lt;/code&gt; is the beginning index of the replacement in a String literal. It’s inclusive, which means if you specify 1, the index 1 of the String will be included in the replacement.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;endIndex&lt;/code&gt; is the ending index of the replacement in a String literal. It’s exclusive, which means if you specify 5, the index 5 of the String will not be included in the replacement. Replacements are made only through index 4.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;replacementString&lt;/code&gt; – The actual replacement String. The specified index range in the String literal will be replaced with this String.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The index of the Character to be replaced is a required parameter, so you can use the &lt;code&gt;indexOf()&lt;/code&gt; method to find it. The following example shows the full Java code to use the &lt;code&gt;StringBuffer.replace()&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/** * Demonstrating the Replace method available in StringBuffer */
private static void useStringBufferReplace() {
  String sourceString = "The world is schön. This is a String with special Character ö";
  StringBuffer buffer = new StringBuffer(sourceString);
  int indexOfUmlauts = buffer.indexOf("ö");
  System.out.println("Source String before replace : " + sourceString + "\n");
  System.out.println("Using StringBuffer.replace() " + buffer.replace(indexOfUmlauts, indexOfUmlauts + 1, "oe") + "\n");
  System.out.println("String buffer after replace : " + buffer);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just like in the StringBuilder case above, StringBuffer.replace() does &lt;em&gt;not&lt;/em&gt; replace all instances of the special character and it &lt;em&gt;does&lt;/em&gt; mutate the original string buffer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source String before replace : The world is schön. This is a String with special Character ö 
Using StringBuffer.replace() The world is schoen. This is a String with special Character ö 
String buffer after replace : The world is schoen. This is a String with special Character ö
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using String.replaceAll()
&lt;/h2&gt;

&lt;p&gt;The last method for replacing strings in Java that I’ll cover is &lt;a href="https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#replaceAll%28java.lang.String,%20java.lang.String%29" rel="noopener noreferrer"&gt;the &lt;code&gt;String.replaceAll()&lt;/code&gt; method&lt;/a&gt;. It uses a regular expression to check if a matching substring needs replaced. The signature of the &lt;code&gt;String.replace()&lt;/code&gt; method is shown here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public String replaceAll(String regex, String replacementString)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;regex&lt;/code&gt; is the regular expression to be matched to find the substring.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;replacementString&lt;/code&gt; is the String that will replace the matched substring.
## The Difference Between String.replaceAll() and String.replace()
Based on the name alone, you might guess that &lt;code&gt;replaceAll()&lt;/code&gt; will replace all occurrences of a character or a substring, and you’d be correct, but &lt;code&gt;String.replace()&lt;/code&gt; also replaces all occurrences of a character or a substring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The only difference between the two is that &lt;strong&gt;with replaceAll(), you can use a regular expression to match the substring that needs to be replaced, whereas with replace(), you &lt;em&gt;cannot&lt;/em&gt; use a regex&lt;/strong&gt;. It accepts only &lt;code&gt;Character&lt;/code&gt; or &lt;code&gt;CharSequence&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Therefore, use &lt;code&gt;replaceAll()&lt;/code&gt; when you don’t know the exact substring to be replaced but you can find it using a regular &lt;a href="https://www.w3schools.com/java/java_regex.asp" rel="noopener noreferrer"&gt;expression&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For example, you may get an HTML String response when you consume a RESTful service from your Java program. Within the HTML, you may want to extract only the text and ignore all the HTML tags.&lt;/p&gt;

&lt;p&gt;The following example demonstrates how to use &lt;code&gt;replaceAll()&lt;/code&gt; with a regex to remove all the HTML tags from the response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/** * Demonstrating the replaceAll method using a regular expression */
private static void userStringReplaceAll() {
  String sourceString = "&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;this is heading1&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;";
  String replacedString = sourceString.replaceAll("&amp;lt;(.|\n)+?&amp;gt;", "");
  System.out.println("Source String before replace : " + sourceString + "\n");
  System.out.println("Text without HTMl Tags : " + replacedString + "\n");
  System.out.println("Source String after replace : " + sourceString);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re not familiar with regex syntax, learn &lt;a href="https://www.javatpoint.com/java-regex" rel="noopener noreferrer"&gt;how to generate it here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;When you execute the program above, you’ll see the following output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Source String before replace : &amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;this is heading1&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt; 
Text without HTML tags : this is heading1 
Source String after replace : &amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;this is heading1&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the original string was not modified, but the replaced string has all the tags stripped away. Regex is very useful when you have complicated string replacement rules, so &lt;code&gt;replaceAll()&lt;/code&gt; will be a good method to keep in your toolbox.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In this tutorial, you learned how to use the &lt;code&gt;String.replace()&lt;/code&gt;, &lt;code&gt;StringBuilder.replace()&lt;/code&gt;, and &lt;code&gt;StringBuffer.replace()&lt;/code&gt; methods to replace all occurrences of a substring. You also learned which &lt;code&gt;Char&lt;/code&gt; implementation should be used in case of a single-threaded or multi-threaded Java program, and how to use &lt;code&gt;replaceAll()&lt;/code&gt; with a regular expression.&lt;/p&gt;

&lt;p&gt;If you’re having trouble which string replacement method to use or you have your own suggestions, feel free to leave them in the comments. I look forward to hearing what you think.&lt;/p&gt;

</description>
      <category>java</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Observability vs. Monitoring in DevOps</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Wed, 10 Feb 2021 12:58:42 +0000</pubDate>
      <link>https://forem.com/eyalk100/observability-vs-monitoring-in-devops-194i</link>
      <guid>https://forem.com/eyalk100/observability-vs-monitoring-in-devops-194i</guid>
      <description>&lt;p&gt;If you strip the buzzwords and TLAs from the definition of DevOps? You’ll find that the roles and tasks involved aim mostly for more uptime and less downtime in the SDLC (software development lifecycle). The first step to achieving that is becoming aware of downtime as it happens with the help of monitoring solutions. Only then can you respond and resolve the issue in a timely manner that minimizes the dreaded and expensive downtime of software development teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  The high cost of downtime
&lt;/h2&gt;

&lt;p&gt;The importance of ensuring uptime cannot be understated. This is because when DevOps teams are slow to resolve a critical incident? The costs are high – very high. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The average cost per ticket in North America is $15.56. This cost increases as the ticket gets escalated, with an L3 ticket coming at approximately $80-$100 and more.&lt;/strong&gt; In a survey conducted by ITIC, 33% of respondents noted that the cost of one hour of downtime can reach $1 million, and sometimes even up to $5 million.&lt;/p&gt;

&lt;p&gt;Data center outages are costly as well. &lt;strong&gt;Every minute in the data recovery journey can cost from $137 to $427. The average hourly cost of an infrastructure failure is estimated at $100K, and the average cost of a critical application failure is between $500K to $1M per hour.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1tjDhJAJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fd6z9e7valzo4hzcbjol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1tjDhJAJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fd6z9e7valzo4hzcbjol.png" alt="cost of data center outage chart"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s clear that when time costs that much money? You need to respond at lightning speed. Which means you need to be aware of any outage or downtime in real or near-real-time. This is where monitoring and observability come into play.&lt;/p&gt;

&lt;p&gt;Let’s take a look at each, how they are different from each other, and why every DevOps team needs both in their incident management and resolution arsenal.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is monitoring in DevOps?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monitoring systems enable DevOps engineers to view and understand the state of a system using a predefined set of metrics and logs.&lt;/strong&gt; By monitoring the behavior of various components in a system, DevOps engineers can be first on the scene to detect failures when they occur. &lt;/p&gt;

&lt;p&gt;Moreover, monitoring plays a vital role in enabling the analysis of long-term trends, dashboard design, and alerting. &lt;/p&gt;

&lt;p&gt;Monitoring in DevOps supports three main incident management goals:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Issue detection&lt;/strong&gt; of incidents such as outages, service degradations, bugs, and unauthorized activity; alerting to such issues when they arise and presenting relevant data via dashboards.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Issue resolution&lt;/strong&gt; by answering the question “what” and “where,” and delivering information that supports troubleshooting and root cause analysis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Continuous improvement&lt;/strong&gt; of the software delivery process by providing insights that support enhanced capacity and financial planning, trending, performance engineering, and reporting.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Ultimately, monitoring in the DevOps CI-CD pipeline drives the collection of the data required to support automated problem detection and alerting, manual debugging when necessary, and overall system health analysis&lt;/strong&gt; – each of which is critical to accelerated incident resolution.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is observability in DevOps?
&lt;/h2&gt;

&lt;p&gt;If monitoring is a tree in DevOps incident resolution? Then observability is the forest. That is, if monitoring lets you know when and where something has gone wrong, observability helps you see the bigger picture (i.e. the forest for the trees), by answering ‘why did it go wrong?’.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Having observability means being able to extract actionable insights from the monitoring tool logs.&lt;/strong&gt; With these insights, you can have a fuller picture of the health and performance of your systems, applications, and infrastructure.&lt;/p&gt;

&lt;p&gt;The primary components of observability are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Logging&lt;/strong&gt; for keeping a record of incidents so that teams can learn from previous events to accelerate finding the source and reason for an error. This plays a critical role in debugging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tracing&lt;/strong&gt;, which is regarded by some as the most important part of observability, as it enables the understanding of the relationship between the cause and effect of an issue. Traces are often visualized through a waterfall graph, enabling developers to understand the time taken in a system, across queues, network hops, and servers. Ultimately, it makes the observable system more effective and drives root cause identification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metrics&lt;/strong&gt; are the quantitative data that is collected, and enables developers to spot trends that emerge over days, weeks, and months.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among the key benefits of observability is in the process of transforming masses of data into insights that are actionable and accessible to anyone. &lt;strong&gt;Without the proper tools, you find yourself with more and more devices monitored, and a growing mass of logs that are created every second.&lt;/strong&gt; In such a case data can be more of a bane than a benefit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Employing observability provides access to knowledge on how to solve anomalies.&lt;/strong&gt; The more data that is collected and analyzed, the higher the likelihood that this data can be leveraged to accelerate incident resolution. It may even help in pre-empting issues before they arise. &lt;/p&gt;

&lt;h2&gt;
  
  
  Observability vs monitoring: what is the difference?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Monitoring is a subset of observability. Only a system that is observable can be monitored.&lt;/strong&gt; Monitoring tools track the overall health of an application, aggregate data on how it’s performing, and when something goes wrong, alert you to what is happening and where. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Observability, on the other hand, is not something that you do. Rather, observability is something that you &lt;em&gt;have&lt;/em&gt;.&lt;/strong&gt; As opposed to monitoring, observability is proactive, leveraging the logs of monitoring together with machine learning and causation to deliver visibility and understanding of not only what is happening and where, but why and how to fix it.&lt;/p&gt;

&lt;p&gt;In addition, it’s important to note that ‘observability’ is not just a fancy word for monitoring. It is the whole that is greater than the sum of its monitoring (and other) parts. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zbvuCtPc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/572fzwto0jvw2nzxziou.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zbvuCtPc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/572fzwto0jvw2nzxziou.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To know that something has gone wrong is important – and that’s what we have monitoring for. But, when it comes down to it, knowing when something has gone wrong is simply not enough in today’s software development world. &lt;/p&gt;

&lt;p&gt;What DevOps teams need are insights – better, wider, more accurate. The kind that are only possible with observability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;By knowing the difference between monitoring and observability and the goal of each, the symbiotic relationship between the two can be leveraged for powerful incident resolution acceleration.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Top 10 Most Common Java Vulnerabilities You Need to Prevent</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Tue, 15 Dec 2020 12:56:48 +0000</pubDate>
      <link>https://forem.com/eyalk100/top-10-most-common-java-vulnerabilities-you-need-to-prevent-oko</link>
      <guid>https://forem.com/eyalk100/top-10-most-common-java-vulnerabilities-you-need-to-prevent-oko</guid>
      <description>&lt;p&gt;It’s easy to think that our code is secure. &lt;strong&gt;Vulnerabilities or potential exploits are often the things we think about last.&lt;/strong&gt; Most of the time, our thoughts are preoccupied with sprints, scrums, meeting notes, and whatever the latest pivots marketing got approved are.&lt;/p&gt;

&lt;p&gt;In a world where development speed takes precedence over code security, this can be a genuine issue. A breach or a hack can cost a business big dollars, if not kill it altogether. According to IBM’s 2020 Cost of Data Breach Report, &lt;strong&gt;the average total cost of a breach sits at 3.86 million US dollars.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The worst part of this is that it takes an average of 280 days to identify and contain the breach. Data is digital gold, and your code is the vessel that holds it.&lt;/p&gt;

&lt;p&gt;While Java is considered relatively safe because it is a server-side language, there are still multiple ways to attack and access things you want to remain private.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jYm7Q6x4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mvzvmafhrtva8jsff5l4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jYm7Q6x4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mvzvmafhrtva8jsff5l4.png" alt="What is the most disturbing fact you know? 3 billion+ devices run java."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To help you get a head start on the exploits your code may develop, we’ve listed the top 10 most common Java vulnerabilities, and how you can (and should) prevent them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Code Injections
&lt;/h2&gt;

&lt;p&gt;Every application that accepts input is vulnerable to code injections. &lt;strong&gt;A code injection occurs when the data passed through the input causes unintended side-effects to how your program runs or returns data.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you think about it, a form is a two-way process. Someone enters the data, the application consumes the data and returns a result. When that result is not what you expect it to be but something else, it can leave your application in a vulnerable state.&lt;/p&gt;

&lt;p&gt;Code injections happen a lot, and are far easier than you think to execute. In 2010, a Japanese developer noticed that you could send HTML as tweets. With a sprinkle of JavaScript inside the HTML, he sent a little Twitter worm off around midnight when no one was really supposed to be awake.&lt;/p&gt;

&lt;p&gt;What did this little piece of code do?&lt;/p&gt;

&lt;p&gt;Every time a user would hover over it, they would instantly retweet it. So when one of their followers was scrolling through, they might just retweet that little worm. This resulted in a chain effect of over 3000 retweets within a few minutes.&lt;/p&gt;

&lt;p&gt;Though Twitter doesn’t only use Java in its stack, the cautionary event can be applied to protecting your input forms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The easiest method is to apply input validation with output sanitizing and escaping.&lt;/strong&gt; This means that any attempts at sending HTML code will be parsed or rejected, depending on what your application is doing.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Command Injections
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An OS command injection, or also commonly known as a shell injection, is a security vulnerability that allows attackers to execute shell commands on the server that’s running your application.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;PHP is often the target for command injections because it calls a sh/bash/cmd by default. Java, however, performs a fork() of the given command to create child processes and pass it the given arguments.&lt;/p&gt;

&lt;p&gt;However, this doesn’t guarantee that your code is safe.&lt;/p&gt;

&lt;p&gt;Your application may be segmented into different levels of legacy code stitched together to form the final product. These &lt;strong&gt;legacy products can act as entry ways for shell command injections.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, you might need to issue a command line to your server – like sending a confirmation email. Rather than using Runtime.exec() to tap into a server, it’s better to use the available Java API located at javax.mail.*&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Connection String Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Connection strings are a set of definitions that are used to connect an application to a data source.&lt;/strong&gt; It may connect to your relational databases, LDAP directories and files.&lt;/p&gt;

&lt;p&gt;For a database connection string injection, there are four parameters that &lt;strong&gt;a malicious user would need: the data source, the initial catalog, the user id, and password.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Connection string attacks happen when a bad actor gains access by injecting parameters into the connect strings using semicolons as separators.&lt;/p&gt;

&lt;p&gt;The issue here is that some database providers have no limit cap and run on a ‘last one wins’ algorithm. This means that an attacker can run multiple connection injection strings, pollute them with duplicate parameters and the database will accept the valid combination. &lt;/p&gt;

&lt;p&gt;As a result, the attacker ends up bypassing the normal authentication process without getting locked out.&lt;/p&gt;

&lt;p&gt;For example, an injected connection string can look something like this:&lt;/p&gt;

&lt;pre&gt;
&lt;p&gt;
Data Source = myDataSource; Initial Catalog = db; Integrated Security = no; User ID = myUsername; Password = XXX; Intergrated Security = true; Data Source = myDataSource; Initial Catalog = db; Integrated Security = no; User ID = myUsername; Password = XXX; Intergrated Security = no;
&lt;/p&gt;
&lt;/pre&gt;

&lt;p&gt;Once in, the malicious user can hijack the credentials and modify them to whatever they want.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. LDAP Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;An LDAP injection exploits input validations and injects executable queries.&lt;/strong&gt; LDAP is the Lightweight Directory Access Protocol, which is an open and cross-platform protocol used for directory service authentication.&lt;/p&gt;

&lt;p&gt;LDAP is a communication language that applications can use to access directory servers. These directory servers often store usernames, passwords, account details and other information that can be shared with other entities on the network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;LDAP injections can happen when an application inserts unsanitized inputs directly into an LDAP statement.&lt;/strong&gt; When this occurs, the attacker can use the LDAP filter syntax causing the server to execute other queries and LDAP statements.&lt;/p&gt;

&lt;p&gt;The easiest way to prevent LDAP injection is to ensure that LDAP special characters – ( ) ! | &amp;amp; * are escaped or rejected at validation.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Reflected XSS
&lt;/h2&gt;

&lt;p&gt;A reflected XSS, or reflected cross site scripting, is the process of adding malicious scripts that is activated through a link. The request then sends the user to somewhere else.&lt;/p&gt;

&lt;p&gt;For example, a reflected XSS can be embedded to blend in with the rest of the site in a user comment section. The user may click on it and end up going to a 3rd party site and then redirected back to the original site.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---7N3ddf5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/owjpdwztoeih4bexidad.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---7N3ddf5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/owjpdwztoeih4bexidad.jpg" alt="Translate server error"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whilst at the 3rd party, malicious activities such as cookie or session stealing may occur. &lt;strong&gt;Although it is hard to monitor reflected XSS, spam filters on links submitted can help reduce the frequency.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Resource Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Resource injections occur when the attacker successfully changes the resource identifiers used by the application to perform malicious tasks.&lt;/strong&gt; This might be changing the port number, modifying the file name, and gaining the ability to execute or access other resources.&lt;/p&gt;

&lt;p&gt;How can this happen? Usually when the application defines the resource via user input.&lt;/p&gt;

&lt;p&gt;For example, imagine that an attacker gains access to a shopping site via connection string injection, or has successfully stolen your user’s details via XSS. They can now modify or query details using resource injection. Your attacker can cause havoc by ordering things from the site, modifying or stealing more information about your customer without them knowing.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. SQL Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SQL injection is the process of injecting SQL within data requests that results in the backend application giving back confidential data or executing malicious scripting content on the database.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This can result in a complete compromise on the host, access to data and breaches of privacy. Not only this, SQL injection can result in data loss or corruption, and potentially lock you out of your own database. When this happens, the injection has fully taken control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The easiest fix to this is to ensure that you validate on the server-side.&lt;/strong&gt; Frontend inputs can be easily bypassed and the backend is the backstop to prevent unwanted characters, such as spaces and ‘ ‘ quote marks, to trickle through.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EAReymIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/afpn2l80k97c1h9ufcj9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EAReymIu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/afpn2l80k97c1h9ufcj9.png" alt="Hi, this is your son's school. we're having some computer trouble"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;[Source: &lt;a href="https://xkcd.com/327/"&gt;https://xkcd.com/327/&lt;/a&gt; ]&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Second Order SQL Injection
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Second order SQL injection is a two-step process.&lt;/strong&gt; First, &lt;strong&gt;the attacker adds something to your application&lt;/strong&gt; but doesn’t immediately execute it. They might be waiting for more data or waiting for a trigger activity.&lt;/p&gt;

&lt;p&gt;This is where second-order SQL injection differs from normal SQL injections.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The attacker injects code into the table row, which is deemed as a trusted source. That table row is then called, causing the attack to move from its dormant state to active execution.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing for second-order SQL is harder because of its often covert nature.&lt;/p&gt;

&lt;p&gt;For example, the malicious user signs up with the username ‘ or ‘hacker’=’hacker&lt;/p&gt;

&lt;p&gt;This means that ‘ or ‘hacker’=’hacker gets stored in the database. The database may use the following query to verify a user’s identity:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from creditcards WHERE username = '&amp;lt;usernamehere&amp;gt;';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So when the username is ‘ or ‘hacker’=’hacker, the final query looks something like this:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;SELECT * from creditcards WHERE username = '' or 'hacker'='hacker';&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then when you go to login, the user name completes the validation query, giving access to other users and their account details.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Stored XSS
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A stored XSS, or persistent XSS attack takes place when an attacker injects a script into the content of a website or app.&lt;/strong&gt; Unlike reflected XSS where third party links are embedded, store XSS is more dangerous in that it doesn’t require the user to interact with it.&lt;/p&gt;

&lt;p&gt;Social media sites are particularly vulnerable to stored XSS attacks because of the platform’s nature. Users are encouraged to post and interact.&lt;/p&gt;

&lt;p&gt;XSS is also commonly known as web worms, where the user ends up with the offending element and it executes on the browser. This attack can lead to stolen cookies, account information or some additional function through account impersonation.&lt;/p&gt;

&lt;p&gt;XSS can be triggered in four places and is often done through JavaScript – &lt;a class="comment-mentioned-user" href="https://dev.to/post"&gt;@post&lt;/a&gt;
.title, post.url, &lt;a class="comment-mentioned-user" href="https://dev.to/post"&gt;@post&lt;/a&gt;
.id and &lt;a class="comment-mentioned-user" href="https://dev.to/post"&gt;@post&lt;/a&gt;
.footer_attr&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To prevent this, rejecting or escaping special characters likes &amp;lt; &amp;gt; and @ before parsing it can be useful.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. XPath Injection
&lt;/h2&gt;

&lt;p&gt;While JSON is the rising star for data structuring, XML documents are still popular and widely used. XPath is the syntax used for defining parts of an XML document. &lt;strong&gt;The idea behind XPath injections is similar to SQL injections.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The only difference between SQL injection and XPath is that the latter is in an XML format. This process of sending malformed data can be easily achieved if the attacker figures out the XML structure.&lt;/p&gt;

&lt;p&gt;This allows the attacker to navigate XML documents, gaining access to various information such as username and password details.&lt;/p&gt;

&lt;p&gt;Often, an XPath injection occurs when the query is built on unvalidated inputs. The trick to prevent XPath injections is to use precompiled XPaths. &lt;strong&gt;Avoid taking in full expressions from an unsecured source. If you have to parametrize your XPath, isolate it to string only parameters to prevent your query from getting hijacked.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LXeQaxnp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hy5d587wny9rymqoxvsp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LXeQaxnp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hy5d587wny9rymqoxvsp.png" alt="A programmer was walking out of door for work, his wife said &amp;quot;while you're out, buy some milk&amp;quot; and he never came home."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For most injections, validating user inputs before you consume them is the easiest way to prevent potential attacks. It’s easy to offload the task over to the frontend, but they are only the first line of defense that’s not always guaranteed to hold.&lt;/p&gt;

&lt;p&gt;While Java can be frontend and backend simultaneously, it’s still good practice to check that whatever your user gives you is what you expect it to be. Setting up your validation parameters may be a matter of identifying and specifying what’s allowed rather than trying to figure out and eliminate everything else.&lt;/p&gt;

</description>
      <category>java</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>21 Best IntelliJ Plugins for 2019 (100% Free)</title>
      <dc:creator>Eyal Katz</dc:creator>
      <pubDate>Thu, 21 Nov 2019 13:39:24 +0000</pubDate>
      <link>https://forem.com/eyalk100/21-best-intellij-plugins-for-2019-100-free-535j</link>
      <guid>https://forem.com/eyalk100/21-best-intellij-plugins-for-2019-100-free-535j</guid>
      <description>&lt;p&gt;&lt;span&gt;Like other IDEs or CMSs before it, IntelliJ has quickly become more than an IDE. With its vast plugin marketplace, IntelliJ has turned into a full-fledged platform for all Java related coding. Have no doubt, JetBrain’s decision to open source and allow external developers to develop solutions on top of it is a strategic one. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Keep that in mind because if you use IntelliJ this will affect you. In fact, at Codota we like to consider ourselves data based swamis and are therefore predicting that in about 2 years from now, you’ll be staring at your IDE wondering how did IntelliJ become all about the plugins so quickly?!&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;We also like to help our users stay ahead of the curve and that’s why we put together this comprehensive list of all the plugins that will lead this shift. &lt;/span&gt;&lt;b&gt;We based our choices on a variety of different factors - be it the plugin’s popularity in the JetBrains directory, the search volume that the problem they look to solve gets, or their aggregated review score&lt;/b&gt;&lt;span&gt;. All these factors, and others, were taken into consideration when putting together this list. &lt;/span&gt;&lt;/p&gt;

&lt;h2&gt;&lt;b&gt;Top 21 JetBrains IntelliJ Plugins for 2019&lt;/b&gt;&lt;/h2&gt;

&lt;h3&gt;
&lt;b&gt;1. Maven Helper&lt;/b&gt;&lt;span&gt; &lt;/span&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.codota.com/wp-content/uploads/2019/01/screenshot_14504.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fscreenshot_14504.png" alt="maven helper plugin intellij"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://plugins.jetbrains.com/plugin/7179-maven-helper" rel="noopener noreferrer"&gt;Maven Helper plugin&lt;/a&gt; provides an easy way to &lt;strong&gt;find and exclude conflicting dependencies, actions to run/debug maven goals for a module that contains the current file or on the root module, and actions to run/debug the current test file&lt;/strong&gt;. It's really a great time saver for solving dependency issues.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;2. Codota&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/completion-illustration.9b7f8228e26c68205e346394357497b8.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fcompletion-illustration.9b7f8228e26c68205e346394357497b8-1024x630.jpg" alt="codota-completions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Shameless plug - got to do it but before you judge listen in… the &lt;a href="https://plugins.jetbrains.com/plugin/7638-codota-" rel="noopener noreferrer"&gt;Codota plugin&lt;/a&gt; helps you &lt;strong&gt;code faster and with fewer pesky errors&lt;/strong&gt;. Codota &lt;/span&gt;&lt;span&gt;completes lines of code based on millions of Java programs, along with your own unique context (open it from within the IDE using Ctrl + Shift + O). You can also find commonly used open-source Java code snippets for the class or method you're using in &lt;a href="https://www.codota.com/code/" rel="noopener noreferrer"&gt;the code search&lt;/a&gt;. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.codota.com/get" rel="noopener noreferrer"&gt;&lt;span&gt;Installation Instructions&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;3. Add to gitignore&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;With &lt;a href="https://plugins.jetbrains.com/plugin/10550-add-to-gitignore" rel="noopener noreferrer"&gt;Add to gitignore&lt;/a&gt; you can create an &lt;strong&gt;automated protocol to ignore a specific path&lt;/strong&gt;. You can track .gitignore files in your repository named .gitignore. Git uses it to determine which files and directories to ignore before you commit. This handy little plugin lets you do just that straight from your IDE.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;4. String Manipulation&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/string-manipulation-1.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fstring-manipulation-1.png" alt="string manipulation plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;This plugin is pretty straightforward. Use &lt;a href="https://plugins.jetbrains.com/plugin/2162-string-manipulation" rel="noopener noreferrer"&gt;String Manipulation&lt;/a&gt; to - well, &lt;strong&gt;manipulate strings&lt;/strong&gt;. Perform a variety of different tasks on strings such as &lt;strong&gt;converting to camel case, capitalizing, escaping string in Java, and more&lt;/strong&gt;. &lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;5. Grep Console &lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/grep-console-e1548171769474.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fgrep-console-e1548171769474.png" alt="grep console plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;a href="https://plugins.jetbrains.com/plugin/7125-grep-console" rel="noopener noreferrer"&gt;Grep Console&lt;/a&gt; enables you to &lt;strong&gt;define a series of regular expressions which will be tested against the console output&lt;/strong&gt;. &lt;/span&gt;&lt;span&gt;Every expression that matches a line will change the style of the whole line/parts of it.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;6. Nyan Progress Bar&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.codota.com/wp-content/uploads/2019/01/1_l5qGjWmNiKz6rwyreUmdTQ.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2F1_l5qGjWmNiKz6rwyreUmdTQ.png" alt="nyan progress bar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Nothing wrong with a little bit of fun in your IDE and nothing is more fun than Nyan cat. So how about a &lt;strong&gt;Nyan progress bar for those endless waits for rebuilds&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;7. CamelCase&lt;/strong&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://plugins.jetbrains.com/plugin/7160-camelcase" rel="noopener noreferrer"&gt;Great plugin&lt;/a&gt; that &lt;strong&gt;switches easily between CamelCase, camelCase, snake_case, SNAKE_CASE&lt;/strong&gt;, well...you get the point. Wish they had one for blog writing too.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;8. Rainbow Brackets&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/rainbow-brackets.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Frainbow-brackets-1024x344.png" alt="rainbow brackets plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;I love &lt;a href="https://plugins.jetbrains.com/plugin/10080-rainbow-brackets" rel="noopener noreferrer"&gt;Rainbow Brackets / &lt;/a&gt;&lt;/span&gt;&lt;span&gt;Parentheses for IntelliJ. This useful tool &lt;strong&gt;saves you the confusion of selecting which bracket needs to be closed&lt;/strong&gt;. Each pair of brackets/parentheses has a different color. Pretty simple, but cool. Plus, this plugin adds some color to your otherwise pale code.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;9. CheckStyle-IDEA&lt;/strong&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;This plugin provides both &lt;strong&gt;real-time and on-demand scanning of Java files with CheckStyle from within IDEA&lt;/strong&gt;. Checkstyle is a static code analysis tool used for checking if Java source code is compiling correctly. &lt;a href="https://plugins.jetbrains.com/plugin/1065-checkstyle-idea" rel="noopener noreferrer"&gt;This awesome plugin&lt;/a&gt; connects to CheckStyle you do it from your IDE.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;10. AWS Toolkit&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/aws-logo-left-aligned.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Faws-logo-left-aligned-e1548175465669.png" alt="aws logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;a href="https://plugins.jetbrains.com/plugin/11349-aws-toolkit" rel="noopener noreferrer"&gt;AWS Toolkit&lt;/a&gt; is an open-source plugin used to &lt;strong&gt;make AWS application development easier&lt;/strong&gt;. Use the toolkit to create, test, and debug apps built on AWS.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;11. EduTools&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/edutools.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fedutools-1024x506.png" alt="edutools plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;You don't have to be Joshua Bloch or Herbert Schildt to teach Java. &lt;a href="https://plugins.jetbrains.com/plugin/10081-edutools" rel="noopener noreferrer"&gt;EduTools&lt;/a&gt; helps you&lt;strong&gt; teach (and learn) IntelliJ based programming languages right in your IDE&lt;/strong&gt;. This is done in the form of coding tasks with instant verification and feedback.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;12. BashSupport &lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/bashsupport.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fbashsupport.png" alt="bashsupport logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Bash language support &lt;a href="https://plugins.jetbrains.com/plugin/4230-bashsupport" rel="noopener noreferrer"&gt;for IntelliJ&lt;/a&gt;. The open source software &lt;strong&gt;supports run configurations, rename refactoring, quick fixes, documentation lookup, syntax highlighting, inspections, and plenty more&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;13. Python&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/python-e1548172149208.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fpython-e1548172149208.png" alt="python programming logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;The &lt;/span&gt;&lt;span&gt;&lt;a href="https://plugins.jetbrains.com/plugin/631-python" rel="noopener noreferrer"&gt;Python plugin&lt;/a&gt; &lt;strong&gt;adds full-scale functionality for Python development&lt;/strong&gt;. Integrate Python into your IntelliJ platform. What more could you ask for?!&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;14. JRebel for IntelliJ&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/jrebel.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fjrebel.png" alt="jrebel logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;a href="https://plugins.jetbrains.com/plugin/4441-jrebel-for-intellij" rel="noopener noreferrer"&gt;JRebel&lt;/a&gt; &lt;strong&gt;enhances developer productivity&lt;/strong&gt; - by reloading code changes instantly. It skips the rebuilding, restarting, and redeploying cycle that is common within Java development.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;15. Docker Integration &lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/docker_twitter_share_new-e1548172294223.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fdocker_twitter_share_new-e1548172294223.png" alt="docker container logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;a href="https://plugins.jetbrains.com/plugin/7724-docker-integration" rel="noopener noreferrer"&gt;This plugin&lt;/a&gt; allows you to d&lt;strong&gt;ownload and build&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt; Docker&lt;/strong&gt;&lt;span&gt;&lt;strong&gt; images, create and start Docker containers, and do other related tasks&lt;/strong&gt;. Docker lets developers deploy applications inside containers for testing code in an environment identical to production.&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;16. CSV Plugin &lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/csv-e1548172332567.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fcsv-e1548172332567.png" alt="csv icon"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Lightweight &lt;a href="https://plugins.jetbrains.com/plugin/10037-csv-plugin" rel="noopener noreferrer"&gt;CSV plugin&lt;/a&gt; that allows you to &lt;strong&gt;edit files in CSV/TSV format&lt;/strong&gt;. &lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;17. Eclipse code formatter&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/Eclipse_Logo2014_New-e1548172420461.jpg" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2FEclipse_Logo2014_New-e1548172420461.jpg" alt="eclipse ide logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Basically exactly what it sounds like. Use &lt;a href="https://plugins.jetbrains.com/plugin/6546-eclipse-code-formatter" rel="noopener noreferrer"&gt;Eclipse Code Formatter&lt;/a&gt; to &lt;strong&gt;fix the problem of maintaining a common style for environments including Eclipse &amp;amp; IntelliJ developers&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;18. FindBugs-IDEA&lt;/strong&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.codota.com/wp-content/uploads/2019/01/screenshot_2536-e1550757423752.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fscreenshot_2536-e1550757423752.png" alt="findbugs-idea"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Provides &lt;strong&gt;static byte code analysis to look for bugs in Java code from within IntelliJ IDEA&lt;/strong&gt;. FindBugs is a defect detection tool for Java that uses static analysis to look for more than 200 bug patterns, such as null pointer dereferences, infinite recursive loops, bad uses of the Java libraries and deadlocks.&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;19. AceJump&lt;/strong&gt;&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://blog.codota.com/wp-content/uploads/2019/01/screenshot_16299.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fscreenshot_16299.png" alt="acejump plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://plugins.jetbrains.com/plugin/7086-acejump" rel="noopener noreferrer"&gt;AceJump&lt;/a&gt; allows you to &lt;strong&gt;quickly navigate the caret to any position visible in the editor&lt;/strong&gt;. If no matches can be found on-screen, AceJump will scroll to the next match it can find.&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;20. Zero Width Character Locator &lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/zero-width.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fzero-width.png" alt="zero width plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;We're getting close to the end of our very comprehensive list of IntelliJ plugins. I really like plugins like this one that offer a simple solution to a very common problem. &lt;a href="https://plugins.jetbrains.com/plugin/7448-zero-width-characters-locator" rel="noopener noreferrer"&gt;The Zero Width Character Locator plugin&lt;/a&gt; adds an inspection that prevents some &lt;strong&gt;hard to find bugs related to invisible zero width characters in source code and resources&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;&lt;strong&gt;21. IdeaVim&lt;/strong&gt; &lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;a href="http://blog.codota.com/wp-content/uploads/2019/01/vim.png" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/http%3A%2F%2Fblog.codota.com%2Fwp-content%2Fuploads%2F2019%2F01%2Fvim.png" alt="Ideavim plugin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Finally, the &lt;a href="https://plugins.jetbrains.com/plugin/164-ideavim" rel="noopener noreferrer"&gt;IdeaVim&lt;/a&gt; plugin also made our list. IdeaVim provides Vim emulation in IntelliJ based IDEs. It &lt;strong&gt;includes many of the popular features Vim has to offer: &lt;/strong&gt;&lt;/span&gt;&lt;span&gt;&lt;strong&gt;normal/insert/visual modes, motion keys, deletion/changing, marks, registers, some Ex commands, and much more&lt;/strong&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Thanks for making it all the way down! It may seem like a long list but with the thousands of plugins available for IntelliJ it was not an easy list to compile. So, &lt;strong&gt;if we left out your favorite plugin please let us know in the comments below&lt;/strong&gt;. Happy coding!&lt;/span&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>kotlin</category>
    </item>
  </channel>
</rss>
