feedback-to-code/mozzarella huggingface dataset:
Repository: pinpoint-apm/pinpoint
Issue: Add pinpoint version to system properties while bootstrap start
Labels: enhancement


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java
index 4deb31928844..3f64842b1c5a 100644
--- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java
+++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/PinpointBootStrap.java
@@ -30,6 +30,7 @@
 import com.navercorp.pinpoint.bootstrap.util.IdValidateUtils;
 import com.navercorp.pinpoint.common.PinpointConstants;
 import com.navercorp.pinpoint.common.ServiceTypeProviderLoader;
+import com.navercorp.pinpoint.common.Version;
 import com.navercorp.pinpoint.common.util.BytesUtils;
 import com.navercorp.pinpoint.common.util.SimpleProperty;
 import com.navercorp.pinpoint.common.util.SystemProperty;
@@ -106,6 +107,8 @@ public static void premain(String agentArgs, Instrumentation instrumentation) {
 
         // set the path of log file as a system property
         saveLogFilePath(classPathResolver);
+        
+        savePinpointVersion();
 
         try {
             // Is it right to load the configuration in the bootstrap?
@@ -229,6 +232,11 @@ private static void saveLogFilePath(ClassPathResolver classPathResolver) {
 
         SYSTEM_PROPERTY.setProperty(ProductInfo.NAME + ".log", agentLogFilePath);
     }
+    
+    private static void savePinpointVersion() { 
+        logger.info("pinpoint version:" + Version.VERSION); 
+        SYSTEM_PROPERTY.setProperty(ProductInfo.NAME + ".version", Version.VERSION); 
+    } 
 
     private static String getConfigPath(ClassPathResolver classPathResolver) {
         final String configName = ProductInfo.NAME + ".config";
diff --git a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/ProfilerLibClass.java b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/ProfilerLibClass.java
index 26b9cc5dc98b..c8a9b3bf3134 100644
--- a/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/ProfilerLibClass.java
+++ b/bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/ProfilerLibClass.java
@@ -32,7 +32,8 @@ public class ProfilerLibClass {
             "com.google.common",
             "org.apache.commons.lang",
             "org.apache.log4j",
-            "com.codahale.metrics"
+            "com.codahale.metrics",
+            "com.nhncorp.nelo2"
     };
 
     public boolean onLoadClass(String clazzName) {


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Documentation change in DAO pattern

Removed a redundant word and added an Acronym.


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/dao/src/main/java/com/iluwatar/App.java b/dao/src/main/java/com/iluwatar/App.java
index 878f7b5bfba7..29578d74ea21 100644
--- a/dao/src/main/java/com/iluwatar/App.java
+++ b/dao/src/main/java/com/iluwatar/App.java
@@ -6,7 +6,7 @@
 /**
  * 
  * With the DAO pattern, we can use various method calls to retrieve/add/delete/update data without directly
- * interacting with the data directly. The below example demonstrates basic operations: select, add, update, and delete.
+ * interacting with the data. The below example demonstrates basic operations(CRUD): select, add, update, and delete.
  */
 public class App {
 


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Migrate travis build to container based infrastructure

I was viewing build logs when I found out that we are running build on legacy infrastructure and got a notification for migration to container based infrastructure.

[Travis CI - Why migrate to container based infrastructure](http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade)

One of the best advantages is faster build times


Issue comments:
Shouldn't this be replicable in my fork?

I get `This job is running on container-based infrastructure, which does not allow use of 'sudo', setuid and setguid executables.`

@mafagafogigante Yes that is normal. `sudo` is not yet supported in Travis container environment but as we don't need that we are good to go. I have already migrated my fork to container based infrastructure. But Travis is facing issues downloading dependencies for `naked-objects-intergration` and the build is failing. I need to figure out why is that so. FYI https://travis-ci.org/npathai/java-design-patterns

@npathai I think this is the same build issue I worked on yesterday, see https://github.com/iluwatar/java-design-patterns/commit/185f296a5b03f16edb62d0023441e89ad4365501. Try to catch up your fork from the master and hopefully the problem is fixed.

@iluwatar Thanks that solved the issue. It's done. Generating PR.

I had the same problem of @npathai.

Thanks for fixing it.


Pull request review comments:

Patch that resolved the issue:
diff --git a/.travis.yml b/.travis.yml
index 8ae7361f3b00..e69a17a4f8e1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,4 +13,7 @@ before_install:
   - "sh -e /etc/init.d/xvfb start"
   
 after_success:
-  - mvn clean test jacoco:report coveralls:report
\ No newline at end of file
+  - mvn clean test jacoco:report coveralls:report
+
+# Migration to container-based infrastructure  
+sudo: false


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Integrate with Gitter chat room
Labels: type: enhancement

I recently stumbled upon [Gitter - chat rooms for github](https://gitter.im/) and I think it would be a great idea to integrate with it, because discussions regarding design patterns can be really interesting and may be more suitable in chat format. 


Issue comments:
Yes, why not. We could also setup a mailing list.

@iluwatar Great then. Let's do that. There is one more thing, I was thinking of setting up a wiki page describing usages of all design patterns. Do you think that is a good idea? IMO it would be better search optimized than README.md. We should continue doing what we do in README but we can also set up wiki. If you think it is a good idea then I can create a issue and start working on it.

@npathai Take a look at #56 This is under construction by @noobxgockel I don't think there will be wiki after this task, but nevertheless it is going to be a great step forward from `README.md` Maybe we should re-evaluate the wiki functionality after #56 is live.

I made an issue for the mailing list. It is #186 

@iluwatar Can we set up chat room on priority so that we can start having discussions on our ongoing implementations of patterns. We should also add link to add our gitter chat room in README.

Resolved with https://github.com/iluwatar/java-design-patterns/commit/76fe68f591f6b341a4b6d254a5c4d2d4b4e0cba5

Yayy :+1: 


Pull request review comments:

Patch that resolved the issue:
diff --git a/README.md b/README.md
index 358dfa3f3934..b2b72a358d2f 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
 # Design pattern samples in Java.
 
+[![Join the chat at https://gitter.im/iluwatar/java-design-patterns](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/iluwatar/java-design-patterns?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+
 ![Build status](https://travis-ci.org/iluwatar/java-design-patterns.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/iluwatar/java-design-patterns/badge.svg?branch=master)](https://coveralls.io/r/iluwatar/java-design-patterns?branch=master) <a href="https://scan.coverity.com/projects/5634">
   <img alt="Coverity Scan Build Status"
        src="https://scan.coverity.com/projects/5634/badge.svg"/>


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Half Sync/Half Async pattern
Labels: info: help wanted
epic: pattern

This is a _concurrency_ pattern. The pattern separates asynchronous I/O from the synchronous one. Main thread doesn't block on incoming client requests and long-running operations are offloaded to a dedicated synchronous layer. Processing results are delivered by the means of callbacks.
Some resources:
- http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf
- http://zezutom.blogspot.in/2014/08/concurrency-patterns-half-sync-half.html
- http://www.dre.vanderbilt.edu/~schmidt/cs282/PDFs/6-Concurrency-and-Synchronization-part10.pdf


Issue comments:
Great find, thanks for reporting this.

I am working on it. 

Note to self - we also need to add reference to POSA book with this task in README

Please close this issue, if you are satisfied.

Once #204 is merged we can close this.


Pull request review comments:

Patch that resolved the issue:
diff --git a/README.md b/README.md
index b2b72a358d2f..dc43a2dc5855 100644
--- a/README.md
+++ b/README.md
@@ -1037,6 +1037,8 @@ other words, version numbers are used only for project planning sake.
 * [Spring Data](http://www.amazon.com/Spring-Data-Mark-Pollack/dp/1449323952/ref=sr_1_1)
 * [J2EE Design Patterns](http://www.amazon.com/J2EE-Design-Patterns-William-Crawford/dp/0596004273/ref=sr_1_2)
 * [Marco Castigliego - Step Builder](http://rdafbn.blogspot.co.uk/2012/07/step-builder-pattern_28.html)
+* [Douglas C. Schmidt and Charles D. Cranor - Half Sync/Half Async](http://www.cs.wustl.edu/~schmidt/PDF/PLoP-95.pdf)
+* [Pattern Oriented Software Architecture Vol I-V](http://www.amazon.com/Pattern-Oriented-Software-Architecture-Volume-Patterns/dp/0471958697)
 
 
 # <a name="license">License</a> [&#8593;](#top)


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Document design principles | SOLID | YAGNI
Labels: type: enhancement
info: good first issue

Some of the design principles that I know of are:
- [SOLID](https://en.wikipedia.org/wiki/SOLID_%28object-oriented_design%29) 
- [Tell Don't Ask](http://martinfowler.com/bliki/TellDontAsk.html)
- [YAGNI](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it)
- [KISS](https://en.wikipedia.org/wiki/KISS_principle)
- [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)

These are the foundational principles which lead to design patterns. I think we should document them.


Issue comments:
:+1: 

This could be its own section, like for example the "Idioms" is.

We should borrow some things from here http://webpro.github.io/programming-principles/

@iluwatar That's a great link. I will go through it. Yes it should be in a dedicated section something like "Design guidelines or principles".

I dare to say YAGNI about this very idea.

@iluwatar Awesome link. Why not just reference it in the suggested section? Also keep a fork of it so that if the original repository is removed we still have our copy.

@mafagafogigante I was kinda thinking in the same line. I will change the task to just add reference to the link @iluwatar provided. How does that sound?

@mafagafogigante @npathai This is a good idea. We also may have something to contribute to that repository.

Ok I will pick this up once I am done with #74 Turns out its difficult to work with NIO :smile: 

Great. I think that helping that repository would be a great thing to do.

It's done. Closing this issue.


Pull request review comments:

Patch that resolved the issue:
diff --git a/README.md b/README.md
index a4ec970c9d9b..77282f569fb7 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,17 @@ Reusing design patterns helps to prevent subtle issues that can cause major
 problems, and it also improves code readability for coders and architects who
 are familiar with the patterns.
 
+# Getting started
+
+Before you dive into the material, you should be familiar with various 
+[Programming/Software Design Principles](http://webpro.github.io/programming-principles/). 
+
+Once you are familiar with these concepts you can start drilling down into patterns by any of the following approaches
+
+ - Using difficulty tags, `Difficulty-Beginner`, `Difficulty-Intermediate` & `Difficulty-Expert`.
+ - Using pattern categories, `Creational`, `Behavioral` and others.
+ - Search for a specific pattern. Can't find one? Please report a new pattern [here](https://github.com/iluwatar/java-design-patterns/issues).
+
 # How to contribute
 
 If you are willing to contribute to the project you will find the relevant information in our [developer wiki](https://github.com/iluwatar/java-design-patterns/wiki).


Test patch:
Repository: iluwatar/java-design-patterns
Issue: add getAttackPower method to pattern decorator
Labels: info: help wanted
type: enhancement
info: good first issue

Add getAttackPower method to pattern decorator may make it more easily to understand .

when the troll not add smart decorator , his attack power is 10 ,but when we build the smartTroll , his attack power is 10(the normal troll's attack power) + 20(because smart). So ,it's more easy to understand .


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/decorator/src/main/java/com/iluwatar/decorator/App.java b/decorator/src/main/java/com/iluwatar/decorator/App.java
index 88e1c7103175..a9eabf6068c0 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/App.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/App.java
@@ -23,11 +23,13 @@ public static void main(String[] args) {
 		Hostile troll = new Troll();
 		troll.attack();
 		troll.fleeBattle();
+		System.out.printf("Simple troll power %d.\n", troll.getAttackPower());
 
 		// change the behavior of the simple troll by adding a decorator
 		System.out.println("\nA smart looking troll surprises you.");
 		Hostile smart = new SmartTroll(troll);
 		smart.attack();
 		smart.fleeBattle();
+		System.out.printf("Smart troll power %d.\n", smart.getAttackPower());
 	}
 }
diff --git a/decorator/src/main/java/com/iluwatar/decorator/Hostile.java b/decorator/src/main/java/com/iluwatar/decorator/Hostile.java
index 4df751cca69d..7090725017f4 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/Hostile.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/Hostile.java
@@ -9,6 +9,8 @@ public interface Hostile {
 
 	void attack();
 
+	int getAttackPower();
+
 	void fleeBattle();
 
 }
diff --git a/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java b/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
index 22ba88dc88b8..909f94c952ff 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/SmartTroll.java
@@ -21,6 +21,12 @@ public void attack() {
 		decorated.attack();
 	}
 
+	@Override
+	public int getAttackPower() {
+		// decorated troll power + 20 because it is smart
+		return decorated.getAttackPower() + 20;
+	}
+
 	@Override
 	public void fleeBattle() {
 		System.out.println("The troll calls for help!");
diff --git a/decorator/src/main/java/com/iluwatar/decorator/Troll.java b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
index 11e9b9d1afdf..85d873dbe5c1 100644
--- a/decorator/src/main/java/com/iluwatar/decorator/Troll.java
+++ b/decorator/src/main/java/com/iluwatar/decorator/Troll.java
@@ -11,6 +11,11 @@ public void attack() {
 		System.out.println("The troll swings at you with a club!");
 	}
 
+	@Override
+	public int getAttackPower() {
+		return 10;
+	}
+
 	public void fleeBattle() {
 		System.out.println("The troll shrieks in horror and runs away!");
 	}


Test patch:
Repository: iluwatar/java-design-patterns
Issue: No main method in the Abstract Factory example
Labels: type: bug
info: good first issue

There is no `main` method in the Abstract Factory example.


Issue comments:
I'm working on it!

@tainarareis do you want me to help you?


Pull request review comments:

Patch that resolved the issue:
diff --git a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java
index 5b93f0e46b0c..9a32a091a899 100644
--- a/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java
+++ b/abstract-factory/src/main/java/com/iluwatar/abstractfactory/App.java
@@ -23,6 +23,7 @@ public class App {
   private Castle castle;
   private Army army;
 
+
   /**
    * Creates kingdom
    * 
@@ -77,4 +78,33 @@ public Army getArmy() {
   private void setArmy(final Army army) {
     this.army = army;
   }
+  
+
+  /**
+   * Program entry point
+   * 
+   * @param args command line args
+   */
+  public static void main(String[] args) {
+	  
+	  App app = new App();
+	  
+	  System.out.println("Elf Kingdom");
+	  KingdomFactory elfKingdomFactory;
+	  elfKingdomFactory = app.getElfKingdomFactory();
+	  app.createKingdom(elfKingdomFactory);
+	  System.out.println(app.getArmy().getDescription());
+	  System.out.println(app.getCastle().getDescription());
+	  System.out.println(app.getKing().getDescription());
+	
+	  System.out.println("\nOrc Kingdom");
+	  KingdomFactory orcKingdomFactory;
+	  orcKingdomFactory = app.getOrcKingdomFactory();
+	  app.createKingdom(orcKingdomFactory);
+	  System.out.println(app.getArmy().getDescription());
+	  System.out.println(app.getCastle().getDescription());
+	  System.out.println(app.getKing().getDescription());
+	  
+  }
+  
 }


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Functional approach to Strategy pattern
Labels: info: help wanted
type: enhancement
info: good first issue

The Strategy pattern example should include Java 8 specific solution.

For inspiration, read this: http://alvinalexander.com/scala/how-scala-killed-oop-strategy-design-pattern


Issue comments:

Pull request review comments:

Patch that resolved the issue:
diff --git a/strategy/src/main/java/com/iluwatar/strategy/App.java b/strategy/src/main/java/com/iluwatar/strategy/App.java
index 272e56cf9e51..e2bcfef8a35e 100644
--- a/strategy/src/main/java/com/iluwatar/strategy/App.java
+++ b/strategy/src/main/java/com/iluwatar/strategy/App.java
@@ -5,6 +5,10 @@
  * The Strategy pattern (also known as the policy pattern) is a software design pattern that enables
  * an algorithm's behavior to be selected at runtime.
  * <p>
+ * Before Java 8 the Strategies needed to be separate classes forcing the developer
+ * to write lots of boilerplate code. With modern Java it is easy to pass behavior
+ * with method references and lambdas making the code shorter and more readable.
+ * <p>
  * In this example ({@link DragonSlayingStrategy}) encapsulates an algorithm. The containing object
  * ({@link DragonSlayer}) can alter its behavior by changing its strategy.
  * 
@@ -17,6 +21,7 @@ public class App {
    * @param args command line args
    */
   public static void main(String[] args) {
+    // GoF Strategy pattern
     System.out.println("Green dragon spotted ahead!");
     DragonSlayer dragonSlayer = new DragonSlayer(new MeleeStrategy());
     dragonSlayer.goToBattle();
@@ -26,5 +31,19 @@ public static void main(String[] args) {
     System.out.println("Black dragon lands before you.");
     dragonSlayer.changeStrategy(new SpellStrategy());
     dragonSlayer.goToBattle();
+
+    // Java 8 Strategy pattern
+    System.out.println("Green dragon spotted ahead!");
+    dragonSlayer = new DragonSlayer(
+        () -> System.out.println("With your Excalibur you severe the dragon's head!"));
+    dragonSlayer.goToBattle();
+    System.out.println("Red dragon emerges.");
+    dragonSlayer.changeStrategy(() -> System.out.println(
+        "You shoot the dragon with the magical crossbow and it falls dead on the ground!"));
+    dragonSlayer.goToBattle();
+    System.out.println("Black dragon lands before you.");
+    dragonSlayer.changeStrategy(() -> System.out.println(
+        "You cast the spell of disintegration and the dragon vaporizes in a pile of dust!"));
+    dragonSlayer.goToBattle();
   }
 }
diff --git a/strategy/src/main/java/com/iluwatar/strategy/DragonSlayingStrategy.java b/strategy/src/main/java/com/iluwatar/strategy/DragonSlayingStrategy.java
index e17e5fbf00bf..aa57c34f0fc0 100644
--- a/strategy/src/main/java/com/iluwatar/strategy/DragonSlayingStrategy.java
+++ b/strategy/src/main/java/com/iluwatar/strategy/DragonSlayingStrategy.java
@@ -5,6 +5,7 @@
  * Strategy interface.
  * 
  */
+@FunctionalInterface
 public interface DragonSlayingStrategy {
 
   void execute();


Test patch:
Repository: iluwatar/java-design-patterns
Issue: Callback implemented with lambdas
Labels: info: help wanted
type: enhancement
info: good first issue

In the Callback example show how to implement the same thing with Java 8 lambdas.


Issue comments:
I have added an example, not sure if this is really what you're asking for.


Pull request review comments:

Patch that resolved the issue:
diff --git a/callback/src/main/java/com/iluwatar/callback/LambdasApp.java b/callback/src/main/java/com/iluwatar/callback/LambdasApp.java
new file mode 100644
index 000000000000..19dd17eae441
--- /dev/null
+++ b/callback/src/main/java/com/iluwatar/callback/LambdasApp.java
@@ -0,0 +1,19 @@
+package com.iluwatar.callback;
+
+/**
+ *
+ * This example generates the exact same output as {@link App} however the callback has been
+ * defined as a Lambdas expression.
+ *
+ */
+public class LambdasApp {
+
+  /**
+   * Program entry point
+   */
+  public static void main(String[] args) {
+    Task task = new SimpleTask();
+    Callback c = () -> System.out.println("I'm done now.");
+    task.executeWith(c);
+  }
+}


Test patch:
diff --git a/callback/src/test/java/com/iluwatar/callback/AppTest.java b/callback/src/test/java/com/iluwatar/callback/AppTest.java
index 67046a175590..28d6eaa1cea1 100644
--- a/callback/src/test/java/com/iluwatar/callback/AppTest.java
+++ b/callback/src/test/java/com/iluwatar/callback/AppTest.java
@@ -36,4 +36,22 @@ public void call() {
     assertEquals("Callback called twice", new Integer(2), callingCount);
 
   }
+
+  @Test
+  public void testWithLambdasExample() {
+    Callback callback = () -> callingCount++;
+
+    Task task = new SimpleTask();
+
+    assertEquals("Initial calling count of 0", new Integer(0), callingCount);
+
+    task.executeWith(callback);
+
+    assertEquals("Callback called once", new Integer(1), callingCount);
+
+    task.executeWith(callback);
+
+    assertEquals("Callback called twice", new Integer(2), callingCount);
+
+  }
 }
Repository: iluwatar/java-design-patterns
Issue: Chain of responsiblity pattern - javax.servlet.Filter as real example is missed
Labels: type: enhancement
epic: web site

I think that on the chain of responsibility pattern on the section real word examples the most important java real word example is missed.

I suggest to add there **javax.servlet.Filter** as the best patter for the people who meet this patter the first time.

I could create the pull request if it is needed.


Issue comments:
Thanks @pnowy Please create a pull request and we'll review it.

Pull request has been created!


Pull request review comments:

Patch that resolved the issue:
diff --git a/intercepting-filter/README.md b/intercepting-filter/README.md
index 327f091b1e93..7d53472a077f 100644
--- a/intercepting-filter/README.md
+++ b/intercepting-filter/README.md
@@ -24,6 +24,7 @@ Use the Intercepting Filter pattern when
 
 ## Real world examples
 
+* [javax.servlet.FilterChain](https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/FilterChain.html) and [javax.servlet.Filter](https://tomcat.apache.org/tomcat-8.0-doc/servletapi/javax/servlet/Filter.html)
 * [Struts 2 - Interceptors](https://struts.apache.org/docs/interceptors.html)
 
 ## Credits


Test patch: