Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ DAPR_GRPC_PORT=5001

Now you can go to your IDE (like IntelliJ, for example) and debug your Java application, using port `3500` to call Dapr while also listening to port `3000` to expose Dapr's callback endpoint.

Calls to Dapr's APIs on `http://localhost:3500/*` should work now and trigger breakpoints in your code.
Calls to Dapr's APIs on `http://127.0.0.1:3500/*` should work now and trigger breakpoints in your code.

**If your application needs to subscribe to topics or register Actors in Dapr, for example, then start debugging your app first and run dapr with dummy command last.**

Expand Down
2 changes: 1 addition & 1 deletion docs/constant-values.html
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ <h2 title="io.dapr">io.dapr.*</h2>
<!-- -->
</a><code>public&nbsp;static&nbsp;final&nbsp;<a href="https://docs.oracle.com/javase/8/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
<td><code><a href="io/dapr/utils/Constants.html#DEFAULT_HOSTNAME">DEFAULT_HOSTNAME</a></code></td>
<td class="colLast"><code>"localhost"</code></td>
<td class="colLast"><code>"127.0.0.1"</code></td>
</tr>
<tr class="altColor">
<td class="colFirst"><a name="io.dapr.utils.Constants.HEADER_DAPR_REQUEST_ID">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void setUp() {
public void invokeActorMethod() {
DaprHttp daprHttpMock = mock(DaprHttp.class);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/actors/DemoActor/1/method/Payment")
.post("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/method/Payment")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void setUp() throws Exception {
@Test
public void getActorState() {
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/actors/DemoActor/1/state/order")
.get("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/state/order")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand All @@ -47,7 +47,7 @@ public void getActorState() {
@Test
public void saveActorStateTransactionally() {
mockInterceptor.addRule()
.put("http://localhost:3000/v1.0/actors/DemoActor/1/state")
.put("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/state")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand All @@ -59,7 +59,7 @@ public void saveActorStateTransactionally() {
@Test
public void registerActorReminder() {
mockInterceptor.addRule()
.put("http://localhost:3000/v1.0/actors/DemoActor/1/reminders/reminder")
.put("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/reminders/reminder")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand All @@ -71,7 +71,7 @@ public void registerActorReminder() {
@Test
public void unregisterActorReminder() {
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/actors/DemoActor/1/reminders/reminder")
.delete("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/reminders/reminder")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand All @@ -82,7 +82,7 @@ public void unregisterActorReminder() {
@Test
public void registerActorTimer() {
mockInterceptor.addRule()
.put("http://localhost:3000/v1.0/actors/DemoActor/1/timers/timer")
.put("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/timers/timer")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand All @@ -94,7 +94,7 @@ public void registerActorTimer() {
@Test
public void unregisterActorTimer() {
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/actors/DemoActor/1/timers/timer")
.delete("http://127.0.0.1:3000/v1.0/actors/DemoActor/1/timers/timer")
.respond(EXPECTED_RESULT);
DaprHttp daprHttp = new DaprHttpProxy(3000, okHttpClient);
DaprHttpClient = new DaprHttpClient(daprHttp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class ActorTurnBasedConcurrencyIT extends BaseIT {
@After
public void cleanUpTestCase() {
// Delete the reminder in case the test failed, otherwise it may interfere with future tests since it is persisted.
// It'll have this structure with different values: http://localhost:33997/v1.0/actors/MyActorTest/1/reminders/588e4adc-f902-4596-b12e-3d2955db68b6
// It'll have this structure with different values: http://127.0.0.1:33997/v1.0/actors/MyActorTest/1/reminders/588e4adc-f902-4596-b12e-3d2955db68b6
DaprHttp client = new DaprHttpBuilder().build();
String url = String.format(Constants.ACTOR_REMINDER_RELATIVE_URL_FORMAT, ACTOR_TYPE, ACTOR_ID, REMINDER_NAME);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testHelloWorldState() throws Exception {
2000
);
ManagedChannel channel =
ManagedChannelBuilder.forAddress("localhost", daprRun.getGrpcPort()).usePlaintext().build();
ManagedChannelBuilder.forAddress("127.0.0.1", daprRun.getGrpcPort()).usePlaintext().build();
DaprGrpc.DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);

String key = "mykey";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static void main(String[] args) {

// If port string is not valid, it will throw an exception.
int grpcPortInt = Integer.parseInt(grpcPort);
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", grpcPortInt).usePlaintext().build();
ManagedChannel channel = ManagedChannelBuilder.forAddress("127.0.0.1", grpcPortInt).usePlaintext().build();
DaprBlockingStub client = DaprGrpc.newBlockingStub(channel);

String key = "mykey";
Expand Down
2 changes: 1 addition & 1 deletion sdk/src/main/java/io/dapr/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class Constants {
/**
* Dapr's default hostname.
*/
public static final String DEFAULT_HOSTNAME = "localhost";
public static final String DEFAULT_HOSTNAME = "127.0.0.1";

/**
* Header used for request id in Dapr.
Expand Down
50 changes: 25 additions & 25 deletions sdk/src/test/java/io/dapr/client/DaprClientHttpTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void setUp() throws Exception {
@Test
public void publishEventInvokation() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -56,7 +56,7 @@ public void publishEventInvokation() {
@Test
public void publishEvent() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -68,7 +68,7 @@ public void publishEvent() {
@Test(expected = IllegalArgumentException.class)
public void publishEventIfTopicIsNull() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -80,7 +80,7 @@ public void publishEventIfTopicIsNull() {
@Test(expected = IllegalArgumentException.class)
public void invokeServiceVerbNull() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -92,7 +92,7 @@ public void invokeServiceVerbNull() {
@Test
public void invokeServiceIllegalArgumentException() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -118,7 +118,7 @@ public void invokeServiceIllegalArgumentException() {
@Test(expected = IllegalArgumentException.class)
public void invokeServiceMethodNull() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/publish/A")
.post("http://127.0.0.1:3000/v1.0/publish/A")
.respond(EXPECTED_RESULT);
String event = "{ \"message\": \"This is a test\" }";
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -130,7 +130,7 @@ public void invokeServiceMethodNull() {
@Test
public void invokeService() {
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/invoke/41/method/neworder")
.get("http://127.0.0.1:3000/v1.0/invoke/41/method/neworder")
.respond("hello world");
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -142,7 +142,7 @@ public void invokeService() {
public void simpleInvokeService() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/invoke/41/method/neworder")
.get("http://127.0.0.1:3000/v1.0/invoke/41/method/neworder")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -154,7 +154,7 @@ public void simpleInvokeService() {
public void invokeServiceWithMaps() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/invoke/41/method/neworder")
.get("http://127.0.0.1:3000/v1.0/invoke/41/method/neworder")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -167,7 +167,7 @@ public void invokeServiceWithMaps() {
public void invokeServiceWithOutRequest() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/invoke/41/method/neworder")
.get("http://127.0.0.1:3000/v1.0/invoke/41/method/neworder")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -179,7 +179,7 @@ public void invokeServiceWithOutRequest() {
public void invokeServiceWithRequest() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/invoke/41/method/neworder")
.get("http://127.0.0.1:3000/v1.0/invoke/41/method/neworder")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -191,7 +191,7 @@ public void invokeServiceWithRequest() {
public void invokeBinding() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/bindings/sample-topic")
.post("http://127.0.0.1:3000/v1.0/bindings/sample-topic")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -203,7 +203,7 @@ public void invokeBinding() {
public void invokeBindingNullName() {
Map<String, String> map = new HashMap<>();
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/bindings/sample-topic")
.post("http://127.0.0.1:3000/v1.0/bindings/sample-topic")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -218,7 +218,7 @@ public void getStates() {
State<String> stateKeyValue = new State("value", "key", "etag", stateOptions);
State<String> stateKeyNull = new State("value", null, "etag", stateOptions);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/MyStateStore/key")
.get("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond("\"" + EXPECTED_RESULT + "\"");
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -233,7 +233,7 @@ public void getStates() {
public void getStatesEmptyEtag() {
State<String> stateEmptyEtag = new State("value", "key", "", null);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/MyStateStore/key")
.get("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond("\"" + EXPECTED_RESULT + "\"");
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -245,7 +245,7 @@ public void getStatesEmptyEtag() {
public void getStatesNullEtag() {
State<String> stateNullEtag = new State("value", "key", null, null);
mockInterceptor.addRule()
.get("http://localhost:3000/v1.0/state/MyStateStore/key")
.get("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond("\"" + EXPECTED_RESULT + "\"");
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -258,7 +258,7 @@ public void saveStates() {
State<String> stateKeyValue = new State("value", "key", "etag", null);
List<State<?>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state/MyStateStore")
.post("http://127.0.0.1:3000/v1.0/state/MyStateStore")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -271,7 +271,7 @@ public void saveStatesNull() {
State<String> stateKeyValue = new State("value", "key", "", null);
List<State<?>> stateKeyValueList = new ArrayList();
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state/MyStateStore")
.post("http://127.0.0.1:3000/v1.0/state/MyStateStore")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -286,7 +286,7 @@ public void saveStatesEtagNull() {
State<String> stateKeyValue = new State("value", "key", null, null);
List<State<?>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state/MyStateStore")
.post("http://127.0.0.1:3000/v1.0/state/MyStateStore")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -299,7 +299,7 @@ public void saveStatesEtagEmpty() {
State<String> stateKeyValue = new State("value", "key", "", null);
List<State<?>> stateKeyValueList = Arrays.asList(stateKeyValue);
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state/MyStateStore")
.post("http://127.0.0.1:3000/v1.0/state/MyStateStore")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -310,7 +310,7 @@ public void saveStatesEtagEmpty() {
@Test
public void simpleSaveStates() {
mockInterceptor.addRule()
.post("http://localhost:3000/v1.0/state/MyStateStore")
.post("http://127.0.0.1:3000/v1.0/state/MyStateStore")
.respond(EXPECTED_RESULT);
StateOptions stateOptions = mock(StateOptions.class);
daprHttp = new DaprHttp(3000, okHttpClient);
Expand All @@ -325,7 +325,7 @@ public void deleteState() {
StateOptions stateOptions = mock(StateOptions.class);
State<String> stateKeyValue = new State("value", "key", "etag", stateOptions);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/MyStateStore/key")
.delete("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -337,7 +337,7 @@ public void deleteState() {
public void deleteStateNullEtag() {
State<String> stateKeyValue = new State("value", "key", null, null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/MyStateStore/key")
.delete("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -349,7 +349,7 @@ public void deleteStateNullEtag() {
public void deleteStateEmptyEtag() {
State<String> stateKeyValue = new State("value", "key", "", null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/MyStateStore/key")
.delete("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand All @@ -362,7 +362,7 @@ public void deleteStateIllegalArgumentException() {
State<String> stateKeyValueNull = new State("value", null, "etag", null);
State<String> stateKeyValueEmpty = new State("value", "", "etag", null);
mockInterceptor.addRule()
.delete("http://localhost:3000/v1.0/state/MyStateStore/key")
.delete("http://127.0.0.1:3000/v1.0/state/MyStateStore/key")
.respond(EXPECTED_RESULT);
daprHttp = new DaprHttp(3000, okHttpClient);
daprClientHttp = new DaprClientHttp(daprHttp);
Expand Down
Loading