20190516
- Mybatis$的sql注入問題,#可以防止;
- 爲什麼dms新加了consumer之後,該consumer無法消費之前存在的消息;
- 存在多參數時,mapper.xml用的parameterType爲map,而mapper接口需要用@Param();
- Server deserialize request exception 可能是接收和發送的類結構不一致;
- list爲空時返回給前端空list但不要傳null;
- RPC route mode
- In DEV mode, RPC only looks for services on local machine;
- In TEST mode, RPC looks for test-url first, then try soft balancing;
- In NORMAL mode, use soft balancing supported by config server;
- 注意H2的存儲鍵值對不要加"/";
- 推薦使用null == obj,因爲obj==null 可能會手誤先成obj=null的賦值語句;
- git
- feat:新功能(feature)
- fix:修補bug
- docs:文檔(documentation)
- style: 格式(不影響代碼運行的變動)
- refactor:重構(即不是新增功能,也不是修改bug的代碼變動)
- test:增加測試
- chore:構建過程或輔助工具的變動
20190517
- org.apache.commons.lang3.StringUtils.isBlank()和isEmpty();
20190523
- update 操作的set 後面的字段之間的連接只有最後一個可以用 and。
20190526
- 事務流程不建議過長,因爲後續的RPC或其他組裝事件太長,導致本地事務無法快速commit,本地數據庫連接池或線程池資源有限。解決方案:事務下沉。
20190529
- git rebase -i [startpoint] [endpoint] 前開後閉
- git rebase [startpoint] [endpoint] --onto [branchName]
- git checkout branchName
- git reset --hard 0c72e64、
- git diff commitA commitB --state
- TimeUnit.SECONDS.sleep(1); 取代Thread.sleep
- yield():
- Thread類的方法
- A hint to the scheduler that the current thread is willing to yield. Its current use of a processor. The scheduler is free to ignore this hint.若是沒有忽視會導致線程上下文切換;
- running->runnable
- sleep():
- Thread類的方法
- Causes the current thread to sleep,沒有時間片的消耗;
- 短暫block
- 不會釋放對象鎖
- wait():
- Object的方法
- 暫停執行並釋放對象鎖
- 當前線程進入等待對象池中
- notify():
- Object的方法
- 從對象等待池中移走任意線程並放入鎖標誌等待池中,只有鎖標誌等待池的線程能獲取鎖標誌
- notifyAll():
- Object的方法
- 從對象等待池中移走所有等待那個對象的線程並放到鎖標誌等待池中
- Priority:不能讓業務的優先級嚴重地依賴線程的優先級,藉助優先級來設置業務的權重不可取,因爲當CPU不忙時,優先級的設置對時間片的分配關係不大
- interrupt():
- 由ThreadB打破ThreadA的阻塞狀態
- 已死亡的線程無法interrupt
- 線程默認是非守護線程,jvm中沒有非守護線程就會自動退出。
- sleep()是可中斷方法,捕獲了中斷信號interrupt以後,爲了不影響線程中其他方法的執行,可以將線程的interrupt復位。
- interrupted()和isInterrupted()區別
- interrupted()調用後會直接擦除線程的interrupt標識,下次返回的interrupted()爲false;
- isInterrupted()則不會擦除
- join()
- 也是可中斷方法,有其他線程對當前線程interrupt,則會被捕獲中斷信號並擦除線程額interrupt標誌
- 在ThreaB中join ThreadA會使得currentThreadB進入等待,知道A結束或達到某時間,期間B Blocked.
20190531
- 使用RateLimiter完成簡單的大流量限流